Skip to content

Weave "AttributeError" on AWS Lambda #9

@matdodgson

Description

@matdodgson

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions