示例#1
0
文件: framework.py 项目: cool-RR/Miro
    def _uses_httpclient(*args, **kwargs):
        # if there's already a curl_manager, then this is probably
        # being called in a nested context, so this iteration is not
        # in charge of starting and stopping the httpclient
        if httpclient.curl_manager:
            return fun(*args, **kwargs)

        httpclient.start_thread()
        try:
            return fun(*args, **kwargs)
        finally:
            httpclient.stop_thread()
示例#2
0
文件: framework.py 项目: kmshi/miro
    def _uses_httpclient(*args, **kwargs):
        # if there's already a curl_manager, then this is probably
        # being called in a nested context, so this iteration is not
        # in charge of starting and stopping the httpclient
        if httpclient.curl_manager:
            return fun(*args, **kwargs)

        httpclient.start_thread()
        try:
            return fun(*args, **kwargs)
        finally:
            httpclient.stop_thread()
示例#3
0
文件: controller.py 项目: ndim/miro
 def downloader_shutdown(self):
     logging.info("Shutting down libCURL thread")
     httpclient.stop_thread()
     httpclient.cleanup_libcurl()
     logging.info("Writing HTTP passwords")
     httpauth.write_to_file()
     logging.info("Shutting down event loop thread")
     eventloop.shutdown()
     logging.info("Saving cached ItemInfo objects")
     logging.info("Commiting DB changes")
     app.db.finish_transaction()
     logging.info("Closing Database...")
     if app.db is not None:
         app.db.close()
     signals.system.shutdown()
示例#4
0
 def downloader_shutdown(self):
     logging.info("Shutting down libCURL thread")
     httpclient.stop_thread()
     httpclient.cleanup_libcurl()
     logging.info("Writing HTTP passwords")
     httpauth.write_to_file()
     logging.info("Shutting down event loop thread")
     eventloop.shutdown()
     logging.info("Saving cached ItemInfo objects")
     logging.info("Commiting DB changes")
     app.db.finish_transaction()
     logging.info("Closing Database...")
     if app.db is not None:
         app.db.close()
     signals.system.shutdown()
示例#5
0
文件: daemon.py 项目: kmshi/miro
 def handle_close(self, type_):
     if self.shutdown:
         return
     logging.info("downloader: quitting")
     self.shutdown = True
     eventloop.shutdown()
     from miro.dl_daemon import download
     download.shutdown()
     logging.info("Cleaning up libcurl")
     httpclient.stop_thread()
     httpclient.cleanup_libcurl()
     import threading
     for thread in threading.enumerate():
         if thread != threading.currentThread() and not thread.isDaemon():
             logging.info("joining with %s", thread)
             thread.join()
     logging.info("handle_close() done")
示例#6
0
文件: daemon.py 项目: cool-RR/Miro
 def handle_close(self, type_):
     if self.shutdown:
         return
     logging.info("downloader: quitting")
     self.shutdown = True
     eventloop.shutdown()
     logging.info("Cleaning up libcurl")
     httpclient.stop_thread()
     httpclient.cleanup_libcurl()
     from miro.dl_daemon import download
     download.shutdown()
     import threading
     for thread in threading.enumerate():
         if thread != threading.currentThread() and not thread.isDaemon():
             logging.info("joining with %s", thread)
             thread.join()
     logging.info("handle_close() done")
示例#7
0
文件: command.py 项目: levjj/miro
 def action(self):
     starttime = time.time()
     from miro import httpclient
     from miro.dl_daemon import download
     download.shutdown()
     httpclient.stop_thread()
     eventloop.thread_pool_quit()
     for thread in threading.enumerate():
         if (thread != threading.currentThread()
              and thread.getName() != "MainThread"
              and not thread.isDaemon()):
             thread.join()
     endtime = starttime + DAEMONIC_THREAD_TIMEOUT
     for thread in threading.enumerate():
         if (thread != threading.currentThread() 
             and thread.getName() != "MainThread"):
             timeout = endtime - time.time()
             if timeout <= 0:
                 break
             thread.join(timeout)
     c = ShutDownResponseCommand(self.daemon)
     c.send(callback=self.response_sent)
     self.daemon.shutdown = True
示例#8
0
 def action(self):
     starttime = time.time()
     from miro import httpclient
     from miro.dl_daemon import download
     download.shutdown()
     httpclient.stop_thread()
     eventloop.thread_pool_quit()
     for thread in threading.enumerate():
         if (thread != threading.currentThread()
                 and thread.getName() != "MainThread"
                 and not thread.isDaemon()):
             thread.join()
     endtime = starttime + DAEMONIC_THREAD_TIMEOUT
     for thread in threading.enumerate():
         if (thread != threading.currentThread()
                 and thread.getName() != "MainThread"):
             timeout = endtime - time.time()
             if timeout <= 0:
                 break
             thread.join(timeout)
     c = ShutDownResponseCommand(self.daemon)
     c.send(callback=self.response_sent)
     self.daemon.shutdown = True