Skip to content

Conversation

@spilchen
Copy link
Contributor

@spilchen spilchen commented Jun 1, 2020

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'

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'
@bradmwilliams
Copy link
Contributor

@spilchen In order for you changes to pass the pr-merge check, you'll need to address this error:
You need to run ansible/rebuild_module.sh and include changes in this PR

@spilchen
Copy link
Contributor Author

spilchen commented Jun 3, 2020

Thanks, I ran the script.

@bradmwilliams bradmwilliams merged commit 56afbcd into openshift:master Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants