Second attempt at fixing this stack trace:

Traceback (most recent call last):
  File "/opt/anki_server/src/anki-sync-server/AnkiServer/threading.py", line 95, in _run
    ret = self.wrapper.execute(func, args, kw, return_queue)
  File "/opt/anki_server/src/anki-sync-server/AnkiServer/collection.py", line 58, in execute
    ret = func(*args, **kw)
  File "/opt/anki_server/src/anki-sync-server/AnkiServer/apps/sync_app.py", line 394, in runFunc
    result = func(**data)
  File "/usr/share/anki/anki/sync.py", line 335, in start
    lgraves = self.removed()
  File "/usr/share/anki/anki/sync.py", line 317, in removed
    curs = self.col.db.execute(
AttributeError: 'NoneType' object has no attribute 'execute'

I think it's caused because we create a new Collection object when
one is closed for inactivity, but we're caching the SyncHandler and
MediaHandler object (which contain a reference to the old collection).