Skip to content
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

AttributeError when running in the context of an HTTP request #110

Closed
alewisohn opened this issue Jul 29, 2015 · 10 comments
Closed

AttributeError when running in the context of an HTTP request #110

alewisohn opened this issue Jul 29, 2015 · 10 comments
Labels

Comments

@alewisohn
Copy link

I get random occurrences of the following error:

AttributeError: 'thread._local' object has no attribute 'stack'

I'm using the library in the process of an HTTP request and I think that might be interfering with the use of thread locals.

@bear
Copy link
Owner

bear commented Jul 29, 2015

Which version of the library and Python are you using?

Also, what library are you using for the HTTP results -- Requests? or ???

@alewisohn
Copy link
Author

Python 2.7.6
parsedatetime HEAD (version 1.6?)
Django REST Framework 2.4.2

I receive a POST from Twilio containing a text message that I then run through the evalRanges method before returning my response.

@bear
Copy link
Owner

bear commented Jul 29, 2015

You may be picking up some very experimental code that just landed - I would suggest trying the tagged v1.5 release at

https://github.com/bear/parsedatetime/tree/v1.5

until we have a chance to test and debug this code -- which your issue is the first!

@bear bear added the bug label Jul 29, 2015
@philiptzou
Copy link
Collaborator

Andrew:

Can you post the traceback information here so we can take a deep look
of this problem? Thank you.

Mike Taylor notifications@github.com于2015年7月30日星期四写道:

You may be picking up some very experimental code that just landed - I
would suggest trying the tagged v1.5 release at

https://github.com/bear/parsedatetime/tree/v1.5

until we have a chance to test and debug this code -- which your issue is
the first!


Reply to this email directly or view it on GitHub
#110 (comment).

发自移动版 Gmail

@alewisohn
Copy link
Author

ERROR 2015-07-30 14:21:20,390 base 16657 140359787828992 Internal Server Error: ...
Traceback (most recent call last):
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/rest_framework/views.py", line 401, in dispatch
    response = self.handle_exception(exc)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/rest_framework/views.py", line 398, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/rest_framework/decorators.py", line 50, in handler
    return func(*args, **kwargs)
  File "/opt/sitterfied/sitterfied/flows/views.py", line 50, in booking_requests
    start, end, type = calendar.evalRanges(text, get_today().timetuple())
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/parsedatetime/__init__.py", line 603, in evalRanges
    VERSION_CONTEXT_STYLE)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/parsedatetime/__init__.py", line 1817, in parse
    with self.context() as ctx:
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/parsedatetime/__init__.py", line 293, in context
    self._ctxStack.push(ctx)
  File "/opt/envs/sitterfied/local/lib/python2.7/site-packages/parsedatetime/context.py", line 24, in push
    self.__local.stack.append(ctx)
AttributeError: 'thread._local' object has no attribute 'stack'

philiptzou added a commit to philiptzou/parsedatetime that referenced this issue Jul 30, 2015
philiptzou added a commit to philiptzou/parsedatetime that referenced this issue Jul 30, 2015
@philiptzou
Copy link
Collaborator

@alewisohn have a try? I think be602b5 fixed this issue. It works for me.

@alewisohn
Copy link
Author

👍

What's the goal behind the code changes? Are you just optimizing or are you adding new features?

@philiptzou
Copy link
Collaborator

Related pull-request here: #106

TL;DR: use new Context object to handle context values during parse and returned as the second value by parse() in new style

@alewisohn
Copy link
Author

Cool, thanks.

@bear
Copy link
Owner

bear commented Jul 30, 2015

yes, this is very cool stuff IMO - thanks @philiptzou for fixing this!

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

No branches or pull requests

3 participants