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

Mailchimp list is not updated automatically for new members #33

Closed
katrinafyi opened this issue Feb 27, 2020 · 4 comments · Fixed by #34
Closed

Mailchimp list is not updated automatically for new members #33

katrinafyi opened this issue Feb 27, 2020 · 4 comments · Fixed by #34

Comments

@katrinafyi
Copy link
Member

It works when testing initially so maybe it only breaks after running for a period of time.

I suspect an unhandled exception is killing the Mailchimp worker. It could be related to this SQLAlchemy error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/signup/lib/python3.6/site-packages/uqcs/workers.py", line 52, in mailchimp_worker
    data['merge_fields']['SNUM'] = item.student_no
  File "/srv/signup/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 282, in __get__
    return self.impl.get(instance_state(instance), dict_)
  File "/srv/signup/lib/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 705, in get
    value = state._load_expired(state, passive)
  File "/srv/signup/lib/python3.6/site-packages/sqlalchemy/orm/state.py", line 660, in _load_expired
    self.manager.deferred_scalar_loader(self, toload)
  File "/srv/signup/lib/python3.6/site-packages/sqlalchemy/orm/loading.py", line 915, in load_scalar_attributes
    "attribute refresh operation cannot proceed" % (state_str(state))
sqlalchemy.orm.exc.DetachedInstanceError: Instance <Student at 0x7fffe9d32be0> is not bound to a Session; attribute refresh operation cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3)
@nicklambourne
Copy link
Member

nicklambourne commented Feb 27, 2020

It is. The ORM object is expiring in between form submission and worker operation. I think passing the generated ID (after the entry is committed to the DB) to the worker and letting the worker re-request the object in a new session (using that ID - which is just an int) is how we can fix this.

@katrinafyi
Copy link
Member Author

That could work, but why would it be expiring? I'd imagine the worker processes incoming items almost instantly.

@nicklambourne
Copy link
Member

Yes, but it's not the same session. The instances are attached to the session they were created in.

@katrinafyi
Copy link
Member Author

#34 did not adequately fix the issue, most likely because the fields are not populated before being expunged.

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

Successfully merging a pull request may close this issue.

2 participants