Thriftpy / thriftpy2

Pure python approach of Apache Thrift.
MIT License
562 stars 89 forks source link

Move some global variables in parser into thread local #264

Closed aisk closed 2 months ago

aisk commented 2 months ago

Related to #232.

I'm not sure if this can totally resolve the original issue, because reproducing a multi-thread bug is hard. I'd like to ship the change because it wouldn't introduce any trouble, and wait to see if there will be more multi-thread issues with the parser. Otherwise, we should introduce a big lock for all these load methods.

aisk commented 2 months ago

The failed tests are caused by https://github.com/pytest-dev/pytest/issues/12263, as that issue said it will be fixed on tornado or pytest repository, so I'll leave as it is for now.

truebit commented 2 months ago

This change would invoke error AttributeError: '_thread._local' obiect has no attribute 'thrift_stack' when using it with example code:

>>> from thriftpy2.parser. parser import parse
>>> note_thrift = parse("path/ to/ note. thrift")