-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
1036a02
commit 725c758
Showing
7 changed files
with
96 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import rpyc | ||
import time | ||
|
||
count = 0 | ||
|
||
def callbackFunc(x): | ||
global count | ||
count += 1 | ||
print x, time.time() | ||
|
||
if __name__ == "__main__": | ||
conn = rpyc.connect("localhost", 12000) | ||
#rpyc.BgServingThread.SERVE_INTERVAL = 0.01 | ||
rpyc.BgServingThread.SLEEP_INTERVAL = 0.0001 | ||
bgsrv = rpyc.BgServingThread(conn) | ||
|
||
test = conn.root.RemoteCallbackTest(callbackFunc) | ||
print test | ||
test.start() | ||
print "doing other things while the callback is being called" | ||
while count < 100: | ||
time.sleep(0.1) | ||
print "done" | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import threading | ||
import rpyc | ||
|
||
|
||
def run_something(callback): | ||
for i in range(100): | ||
callback(i) | ||
|
||
class MyService(rpyc.Service): | ||
def on_connect(self): | ||
print "hi", self._conn._config["endpoints"][1] | ||
def on_disconnect(self): | ||
print "bye", self._conn._config["endpoints"][1] | ||
|
||
class exposed_RemoteCallbackTest(object): | ||
def __init__(self, callback): | ||
self.callback = callback | ||
def start(self): | ||
thd = threading.Thread(target = run_something, args = (self.callback,)) | ||
thd.start() | ||
|
||
|
||
if __name__ == "__main__": | ||
from rpyc.utils.server import ThreadedServer | ||
myServerObj = ThreadedServer(MyService, port=12000, protocol_config={"allow_public_attrs":True}) | ||
myServerObj.start() | ||
|
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