As you noticed, when using the same database connection for the handler
and notification, problems can appear because two different threads are
now using the same connection. This is also the case if you use the
notify() method from outside, since it uses the same connection.
I have solved the problem by using a lock now, but this only solves the
problem when using notify() or (un)listen(), not when using the
connection directly. We also need to import threading because of that.
Not sure if this is a good idea. The alternative is to add an underscore
to the "notify" and "(un)listen" methods to indicate that they should be
only used internally, and require the user to send a notification
manually on another connection instead, as before.
Or, if we already import threading anyway, we could add a method to run
the handler in a thread. What do you think?
-- Chris
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql