When using an internal core, send URIs over IPC if possible (since we can't access...
[bitcoin:spesmilo.git] / ipc.py
1 # -*- coding: utf-8 -*-
2 from PySide.QtCore import *
3
4 class ipc_handler(QThread):
5     have_uri = Signal(object)
6
7     def __init__(self, addr, *args, **kwargs):
8         QThread.__init__(self, *args, **kwargs)
9         self.setTerminationEnabled(True)
10         self._addr = addr
11
12     def run(self):
13         import multiprocessing.connection
14
15         srv = multiprocessing.connection.Listener(self._addr)
16         self._srv = srv
17
18         while True:
19             c = srv.accept()
20             arg = c.recv_bytes()
21             c.close()
22             self.have_uri.emit(arg)
23
24     def stop(self):
25         self.terminate()
26
27 def ipc_send(addr, arg):
28     import multiprocessing.connection
29
30     cln = multiprocessing.connection.Client(addr)
31     cln.send_bytes(arg)