| 360 | self.finalized = False |
| 361 | |
| 362 | def start(self): |
| 363 | if self.finalized: |
| 364 | self.bus.log('Already deamonized.') |
| 365 | |
| 366 | # forking has issues with threads: |
| 367 | # http://www.opengroup.org/onlinepubs/000095399/functions/fork.html |
| 368 | # "The general problem with making fork() work in a multi-threaded |
| 369 | # world is what to do with all of the threads..." |
| 370 | # So we check for active threads: |
| 371 | if threading.active_count() != 1: |
| 372 | self.bus.log('There are %r active threads. ' |
| 373 | 'Daemonizing now may cause strange failures.' % |
| 374 | threading.enumerate(), level=30) |
| 375 | |
| 376 | self.daemonize(self.stdin, self.stdout, self.stderr, self.bus.log) |
| 377 | |
| 378 | self.finalized = True |
| 379 | start.priority = 65 |
| 380 | |
| 381 | @staticmethod |