Beispiel #1
0
def main():
    QT_app = QApplication(sys.argv)
    asyncio_loop = QEventLoop(QT_app)
    asyncio_loop.set_debug(enabled=True)
    set_event_loop(asyncio_loop)
    app = Application(ROUTER)
    app.settings['debug'] = True
    app.listen(8015)
    loop = IOLoop.current()
    loop.start()
Beispiel #2
0
    def setupAsyncLoop(self):
        """
        Install the quamash event loop and enable debugging
        """

        loop = QEventLoop(self)
        asyncio.set_event_loop(loop)
        logging.getLogger('quamash').setLevel(logging.INFO)

        if self.debugEnabled:
            logging.getLogger('asyncio').setLevel(logging.DEBUG)
            loop.set_debug(True)
            warnings.simplefilter('always', ResourceWarning)
            warnings.simplefilter('always', BytesWarning)
            warnings.simplefilter('always', ImportWarning)

        self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=5)

        self.loop = loop
        return loop
            if self.liveview_task is not None:
                self.liveview_task.cancel()
            self.camera_api.close()
            logger.info("finished")
        else:
            if self.camera_api is not None:
                stop_future = asyncio.ensure_future(self.camera_api.stopRecMode())
                stop_future.add_done_callback(self.__pre_close_callback)
                event.ignore()
            else:
                logger.info("finished")


app = QtWidgets.QApplication(sys.argv)
loop = QEventLoop(app)
loop.set_debug(False)
asyncio.set_event_loop(loop)

camera_remote = CameraRemote()
camera_remote.show()

logger = logging.getLogger("cameraremote")
file_handler = logging.FileHandler(filename="cameraremote.log", mode='w')
formatter = logging.Formatter("%(levelname)-8s %(message)s")
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
logger.setLevel(logging.DEBUG)
logger.info("started")

try:
    sys.exit(app.exec_())
Beispiel #4
0
            self.miner_writer.close()
            self.miner_writer = None
        await self.server_task

    async def stop_miner_coro(self):
        if self.proc and not self.proc.returncode:
            assert self.miner_state == "on"
            self.miner_state = "stopping"
            self.log("stopping miner process...")

            # TODO: how do we stop the miner process?

            #self.proc.send_signal(signal.SIGINT)
            #self.miner_writer.write("q".encode())

            # process shuts itself done nicely on disconnect
            if self.miner_writer:
                self.miner_writer.close()
            else:
                self.proc.kill()

            await self.miner_task

if __name__ == "__main__":
    qt = QApplication(sys.argv)
    loop = QEventLoop(qt)
    loop.set_debug(True)
    asyncio.set_event_loop(loop)
    app = App(loop)
    app.run()