Skip to content

Conversation

@aminebouassida
Copy link

@aminebouassida aminebouassida commented Feb 24, 2020

Hello,

When trying to use the package with threading, we always get the following error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/tmp/test.py", line 4, in test
    with oc.project("test-project"), oc.timeout(10 * 60):
  File "/usr/local/lib/python3.6/site-packages/openshift/context.py", line 111, in __enter__
    if len(context.stack) > 0:
AttributeError: '_thread._local' object has no attribute 'stack'

And the root cause turns out to be that the context variable is only initialized for the main thread.
The solution was to overload the threading.local class, to force the initialization for all threads.

Kind regards,
Amine

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 24, 2020
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 24, 2020
@bradmwilliams
Copy link
Contributor

Closing this PR since similar changes to these have been accepted in PR #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants