Commit 0d0fe05
committed
Move initialization of context to thread local object
The context global variable was already thread local, but its
initialization was only being triggered during the initial import of the
package. Moved all of the setup of the context variable to a __init__
function of a class that inherits from threading.local. This ensures
that when a thread starts it will run the __init__ function.
This avoids errors like the following:
Traceback (most recent call last):
File "src/gevent/greenlet.py", line 854, in gevent._gevent_cgreenlet.Greenlet.run
File "/root/src/es-cp4d-locust/env/lib/python3.6/site-packages/locust/user/users.py", line 161, in run_user
user.run()
File "/root/src/es-cp4d-locust/env/lib/python3.6/site-packages/locust/user/users.py", line 128, in run
self.on_start()
File "/root/src/es-cp4d-locust/locustfile.py", line 58, in on_start
CFG['oc']['namespace'])
File "/root/src/py-es-cp4d/db2_eventstore_cp4d/context.py", line 23, in __init__
oc.login(username, password)
File "/root/src/openshift-client-python/packages/openshift/base_verbs.py", line 156, in login
r.add_action(oc_action(cur_context(), "login", cmd_args=['-u', username, '-p', password, cmd_args]))
File "/root/src/openshift-client-python/packages/openshift/context.py", line 37, in cur_context
return context.stack[-1]
File "src/gevent/local.py", line 408, in gevent._gevent_clocal.local.__getattribute__
AttributeError: 'gevent._gevent_clocal.local' object has no attribute 'stack'1 parent 736bcf2 commit 0d0fe05
2 files changed
+26
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 12 | | |
31 | 13 | | |
32 | 14 | | |
| |||
605 | 587 | | |
606 | 588 | | |
607 | 589 | | |
608 | | - | |
609 | | - | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
610 | 604 | | |
611 | | - | |
612 | | - | |
613 | | - | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
0 commit comments