fedmsg_meta_fedora_infrastructure icon indicating copy to clipboard operation
fedmsg_meta_fedora_infrastructure copied to clipboard

fasshim's attempt at preserving memory causes crashes

Open abompard opened this issue 6 years ago • 0 comments

On line 149 of fasshim.py there's an attempt at preserving memory by using the del keyword on an imported module: del fedora.client.fas2. It has the side effect of deleting the module reference from the parent module fedora.client and the next time the execution path enters this function, it will cause a traceback:

  File "lib/python3.5/site-packages/fedmsg_meta_fedora_infrastructure/mailman3.py", line 61, in subtitle
    user = _email_to_username(_full_email_to_email(full_from))
  File "lib/python3.5/site-packages/fedmsg_meta_fedora_infrastructure/mailman3.py", line 39, in _email_to_username
    return email2fas(email, **config)
  File "lib/python3.5/site-packages/fedmsg_meta_fedora_infrastructure/fasshim.py", line 174, in email2fas
    fas_cache = make_fas_cache(**config)
  File "lib/python3.5/site-packages/fedmsg_meta_fedora_infrastructure/fasshim.py", line 118, in make_fas_cache
    fasclient = fedora.client.fas2.AccountSystem(
AttributeError: module 'fedora.client' has no attribute 'fas2'

The earlier "import fedora.client.fas2" in the code did nothing because it was already in sys.modules, but trying to instanciate AccountSystem fails because the reference was deleted in the previous call.

This function is about building a cache so it's unlikely that the execution path goes there again, but it can happen, for example if FAS is not available at the time of the cache build. I don't think we're saving a lot of memory by deleting this reference anyway, so I would suggest to remove the del call altogether.

abompard avatar Feb 07 '18 10:02 abompard