-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SocketStream: add support for unix domain sockets
- Loading branch information
Showing
5 changed files
with
94 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,56 @@ | ||
import rpyc | ||
import time | ||
import tempfile | ||
from rpyc.utils.server import ThreadedServer | ||
from rpyc import SlaveService | ||
import threading | ||
import unittest | ||
|
||
class BaseServerTest(object): | ||
|
||
def _create_server(self): | ||
raise NotImplementedError | ||
|
||
def _create_client(self): | ||
raise NotImplementedError | ||
|
||
class Test_ThreadedServer(unittest.TestCase): | ||
def setUp(self): | ||
self.server = ThreadedServer(SlaveService, port=18878, auto_register=False) | ||
self.server = self._create_server() | ||
self.server.logger.quiet = False | ||
t = threading.Thread(target=self.server.start) | ||
t.setDaemon(True) | ||
t.start() | ||
time.sleep(0.5) | ||
|
||
def tearDown(self): | ||
self.server.close() | ||
|
||
def test_conenction(self): | ||
c = rpyc.classic.connect("localhost", port=18878) | ||
c = self._create_client() | ||
print( c.modules.sys ) | ||
print( c.modules["xml.dom.minidom"].parseString("<a/>") ) | ||
c.execute("x = 5") | ||
self.assertEqual(c.namespace["x"], 5) | ||
self.assertEqual(c.eval("1+x"), 6) | ||
c.close() | ||
|
||
class Test_ThreadedServer(BaseServerTest, unittest.TestCase): | ||
|
||
def _create_server(self): | ||
return ThreadedServer(SlaveService, port=18878, auto_register=False) | ||
|
||
def _create_client(self): | ||
return rpyc.classic.connect("localhost", port=18878) | ||
|
||
class Test_ThreadedServerOverUnixSocket(BaseServerTest, unittest.TestCase): | ||
|
||
socket_path = tempfile.mktemp() | ||
|
||
def _create_server(self): | ||
return ThreadedServer(SlaveService, socket_path=self.socket_path, auto_register=False) | ||
|
||
def _create_client(self): | ||
return rpyc.classic.unix_connect(self.socket_path) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |