Browse Source
Complete Sync implementation in python using python threading. from libpEpAdapter, use: * Session * CallbackDispatcher * Sync Event Queue * retrieve_next_sync_event() * _inject_sync_event() *Sync event processing loop* Write single threaded implementation of the engine function "do_sync_protocol()" using: * retrieve_next_sync_event() (libpEpAdapter) * do_sync_protocol_step() (Engine) The event loop has to be terminated on NULL event. *Sync Thread* Implement Sync thread in python. The Thread has to do: * Init: register_sync_callbacks() * Sync event processing loop () * Cleanup: unregister_sync_callbacks() *Python API* The python API stays backwards compatible. * start_sync() is not allowed to return before "register_sync_callbacks()" in the sync thread has returned * stop_sync() has to use _inject_sync_event from libpEpAdapter * is_sync_active() reports if the python Sync thread is running *Testing* * Update [~fdik]s sync_test.py / sync_handshake.py to work with the new sync impl. * Add a test for start_sync() / stop_sync() continuouslyPYADPT-116

6 changed files with 209 additions and 101 deletions
@ -0,0 +1,35 @@ |
|||
#!/usr/bin/env python3 |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
import pEp |
|||
import time |
|||
pEp.set_debug_log_enabled(True) |
|||
|
|||
def msg2send(message): |
|||
print("MSG2SEND") |
|||
# print(message) |
|||
|
|||
def handshake(me, partner, signal): |
|||
print("HANDSHAKE") |
|||
print(me.fpr) |
|||
print(partner.fpr) |
|||
print(signal) |
|||
|
|||
pEp.message_to_send = msg2send |
|||
pEp.notify_handshake = handshake |
|||
|
|||
alice = pEp.Identity("tedst@alice.com", "alice", "23") |
|||
pEp.myself(alice) |
|||
print(alice.fpr) |
|||
|
|||
while True: |
|||
print("start_sync()") |
|||
pEp.start_sync() |
|||
print("Running...") |
|||
time.sleep(3) |
|||
|
|||
print("shutdown_sync()") |
|||
pEp.shutdown_sync() |
|||
print("END") |
|||
time.sleep(3) |
|||
|
Loading…
Reference in new issue