You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The heartbeat greenlet is spawned on Line#612, while the WorkerRunner.worker_state is set on Line#615. It might have been a rare case where gevent preempted the current thread in such a short gap. But it definitely happened several times.
Describe the bug
The WorkerRunner.heartbeat() method fails with
Exception: WorkerRunner object does not have member 'worker_state'
Looking at the WorkerRunner class:
locust/locust/runners.py
Lines 612 to 615 in f5b89d7
The heartbeat greenlet is spawned on Line#612, while the WorkerRunner.worker_state is set on Line#615. It might have been a rare case where gevent preempted the current thread in such a short gap. But it definitely happened several times.
Suggested Fix
In the WorkerRunner class:
locust/locust/runners.py
Lines 612 to 615 in f5b89d7
Move Line#615 to before Line#612. This guarantees that WorkerRunner.worker_state is set for all calls to heartbeat().
Expected behavior
There should not be an exception.
Actual behavior
The exception occurs.
Steps to reproduce
I'm struggling to reproduce this, but the issue seems easy enough to believe and a possible fix is super easy.
Environment
OS:
Linux 4.4.0-166-generic Execution order? task lifetime? #195-Ubuntu GNU/Linux
Python version:
Python 3.6.9 (2ad108f17bdb, Apr 07 2020, 02:59:05)
[PyPy 7.3.1 with GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
Locust version:
locust 1.1.1
I can't reproduce this, so I can't provide details here. But I ran a master/1worker setup, both created via library calls, not the command line.
The text was updated successfully, but these errors were encountered: