1633 self.pyro_registered = True |
1633 self.pyro_registered = True |
1634 # register a looping task to regularly ensure we're still registered |
1634 # register a looping task to regularly ensure we're still registered |
1635 # into the pyro name server |
1635 # into the pyro name server |
1636 if self._use_pyrons(): |
1636 if self._use_pyrons(): |
1637 self.looping_task(60*10, self._ensure_pyro_ns) |
1637 self.looping_task(60*10, self._ensure_pyro_ns) |
|
1638 # install hacky function to free cnxset |
|
1639 self.looping_task(60, self._cleanup_pyro) |
1638 return daemon |
1640 return daemon |
|
1641 |
|
1642 def _cleanup_pyro(self): |
|
1643 """Very hacky function to cleanup session left by dead Pyro thread. |
|
1644 |
|
1645 There is no clean pyro callback to detect this. |
|
1646 """ |
|
1647 for session in self._sessions.values(): |
|
1648 for thread, cnxset in session._threads_in_transaction.copy(): |
|
1649 if not thread.isAlive(): |
|
1650 self.warning('Freeing cnxset used by dead pyro threads: %', |
|
1651 thread) |
|
1652 session._free_thread_cnxset(thread, cnxset) |
1639 |
1653 |
1640 def _ensure_pyro_ns(self): |
1654 def _ensure_pyro_ns(self): |
1641 if not self._use_pyrons(): |
1655 if not self._use_pyrons(): |
1642 return |
1656 return |
1643 from logilab.common import pyro_ext as pyro |
1657 from logilab.common import pyro_ext as pyro |