I'm using Autobahn Python to make a WAMP server. I open up a database connection in onSessionOpen
of my subclass of WampServerProtocol
, and of course need to close it when the connection closed. However, I can't find a session close handler in either the tutorials or the docs.
There is no WAMP specific session close (since WAMP does not have a closing handshake separate from WebSocket). You can use the onClose
hook.
Another point you might have a look at: the recommended way of accessing databases from Twisted applications is via twisted.enterprise.adbapi
which automatically manages a database connection pool on a background thread pool - independent of frontend protocol instances (like WAMP protocol instances).
Disclaimer: I am original author of Autobahn and work for Tavendo.