Skip to content

werkzeug thread locals does not work under bpython #640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amigrave opened this issue Oct 10, 2016 · 4 comments
Closed

werkzeug thread locals does not work under bpython #640

amigrave opened this issue Oct 10, 2016 · 4 comments

Comments

@amigrave
Copy link

It seems that werkzeug's thread locals can't be used under bpython ?
thread.get_indent() seems coherent tough.

$ bpython
bpython version 0.15 on top of Python 2.7.12+ /usr/bin/python
>>> from werkzeug.local import Local
>>> test = Local()
>>> test.foo = 1
>>> test.foo
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    test.foo
  File "/usr/lib/python2.7/dist-packages/werkzeug/local.py", line 72, in __getattr__
    raise AttributeError(name)
AttributeError: foo

expected behaviour under ipython:

$ ipython
Python 2.7.12+ (default, Sep  1 2016, 20:27:38) 
IPython 4.2.1 -- An enhanced Interactive Python.

In [1]: from werkzeug.local import Local
In [2]: test = Local()
In [3]: test.foo = 1
In [4]: test.foo
Out[4]: 1

I could not find the time to dig deeper unfortunately so I'm just reporting.

@sebastinas
Copy link
Contributor

This might be a side effect of executing in separate greenlets. Does it work if you launch the old interface, i.e. python -m bpython.cli?

@amigrave
Copy link
Author

@sebastinas yes, this case works aside the ansi code outputted as is:

$ python -m bpython.cli
^[[01;33m>>>^[[00m 
^[[01;33m>>>^[[00m 
^[[01;33m>>>^[[00m from werkzeug.local import Local
^[[01;33m>>>^[[00m test = Local()
^[[01;33m>>>^[[00m test.foo = 1
^[[01;33m>>>^[[00m test.foo
1

The problem is that I'm trying to embed bpyhon in Odoo:
odoo/odoo@4e546cd#diff-cb8a380f3459c5ae7d7b6f5e26e030caR76

and Odoo uses werkzeug thread locals so basically the bpython users can't use their favorite shell interface for the moment because it will trigger an error as soon as they use an Odoo method.

Do you have an advice about how I can embed bpython using the old interface (and preferably with a prompt not displaying ansi characters on the terminal) ?

@amigrave
Copy link
Author

@sebastinas Do you think it is possible to use the old interface in bpython.embed() mode ?

@sebastinas
Copy link
Contributor

Closing in favor of #852.

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

No branches or pull requests

2 participants