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

Weave "AttributeError" on AWS Lambda #9

Open
matdodgson opened this issue May 30, 2018 · 1 comment
Open

Weave "AttributeError" on AWS Lambda #9

matdodgson opened this issue May 30, 2018 · 1 comment

Comments

@matdodgson
Copy link

Hi!
Great library - thanks for your work!
I'm hosting some Python 3.6 code on AWS Lambda and I have a strangely intermittent error (occurs about 80% of the time) with aspectlib weave on the Python Requests library. Here's the exception:

File "/var/task/aspectlib/__init__.py", line 413, in weave
weave(item, aspects, **options) for item in target
File "/var/task/aspectlib/__init__.py", line 413, in <listcomp>
weave(item, aspects, **options) for item in target
File "/var/task/aspectlib/__init__.py", line 505, in weave
return weave_instance(target, aspects, **options)
File "/var/task/aspectlib/__init__.py", line 554, in weave_instance
patch_module(instance, attr, _checked_apply(fixed_aspect, realfunc, module=None), **options)
File "/var/task/aspectlib/__init__.py", line 722, in patch_module
setattr(module, alias, replacement)
AttributeError: '__logged__' object attribute 'advising_function' is read-only

Here's my weave call:

weave([Session.send],
      debug.log(stacktrace=False),
      lazy=True)

Never have a problem on my Ubuntu 18 dev machine. Don't have a problem on a normal hosting environment - such as an EC2 instance. This problem only seems to occur on AWS Lambda.

I have made a patch to catch the exception and debug log the error. Please see the pull request. The catch is not very specific; I wanted to avoid recording the rollback of the weave and the "seen = True" part.

@ionelmc
Copy link
Owner

ionelmc commented Jun 6, 2018

I suspect the actual problem is that that weave([Session.send], debug.log(stacktrace=False), lazy=True) is run multiple times in the same process and 20% of the time aws lambda spawns new process when running your code.

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

No branches or pull requests

2 participants