question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using deprecated classes cause a crash

See original GitHub issue

Describe the bug

When using a deprecated old name for a class which has been renamed, locust crashes.

Expected behavior

A deprecation warning should be displayed instead, and the original behavior still executed. The user should still have the option to either crash on, notify about or silently ignore usages of deprecated functionality.

For instance, this should by default still work and log a deprecation warning:

class MyLocust(HttpLocust):
    ...

This should be implemented using warnings.warn('<message>', DeprecationWarning) as shown in Python documentation.

Actual behavior

Locust raises a DeprecationWarning exception.

Steps to reproduce

$ python
>>> from locust import HttpLocust
>>> class X(HttpLocust): ...
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "locust/util/deprecation.py", line 23, in __new__
    raise DeprecationWarning(deprecation_message)
DeprecationWarning: The HttpLocust class has been renamed to HttpUser in version 1.0. For more info see: https://docs.locust.io/en/latest/changelog.html#changelog-1-0

Environment

  • OS: Fedora 30
  • Python version: 3.7
  • Locust version: 1.0.1

See also:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
akaiholacommented, May 25, 2020

Thanks for your replies @cyberw and @heyman,

If the old class names are obsoleted, the exception should be different. Maybe an ImportError with an extended message explaining the rename?

As said, DeprecationWarning isn’t meant to be raised as an exception which terminates execution, but to be used together with warnings.warn().

As you can see e.g. from the Software deprecation article on Wikipedia, “deprecation” really means that a feature is going to be removed while it still works in the version you’re using.

Anyway, we can easily change the class name in our code. I just wanted to point out this confusion for the benefit of other users who hit the issue.

1reaction
heymancommented, May 25, 2020

@akaihola Ah, you’re right. My mental definition of “deprecation” was a bit off apparently. Even though the Wikipedia article do give some support for my (previous) understanding of it (that it could also mean something that was obsolete) in a single sentence without citation 😄:

The term deprecated may also be used when a technical term becomes obsolete, either through change or supersession

Anyway, I’ve now changed (c4bdbd30a52273498a400c19c2ef3672f9fd46ed) so that we’re raising an ImportError instead.

Thanks for reporting it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecation while running an app in Android Studio
I am working in an Application to change and show the date but got a problem and the app crashes when the button...
Read more >
How a deprecated function can crash WordPress site while ...
It is said that deprecated functions used in plugins & themes can crash a wordress website while upgrading to newer version, ...
Read more >
How and When to Deprecate APIs
Starting with J2SE 5.0, you deprecate a class, method, or field by using the @Deprecated annotation. Additionally, you can use the @deprecated Javadoc...
Read more >
Deprecated
An element may be deprecated for any of several reasons, for example, its usage is likely to lead to errors; it may be...
Read more >
Understand SDK Dependencies in Google Maps Platform
When a version of the SDK is deprecated, it will soon be decommissioned. Building with a dependency on a decommissioned SDK version may...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found