@scrypted/server 0.7.10 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @scrypted/server might be problematic. Click here for more details.
- package/package.json +1 -1
- package/python/rpc.py +17 -4
package/package.json
CHANGED
package/python/rpc.py
CHANGED
@@ -29,6 +29,8 @@ class RPCResultError(Exception):
|
|
29
29
|
def __init__(self, caught, message):
|
30
30
|
self.caught = caught
|
31
31
|
self.message = message
|
32
|
+
self.name = None
|
33
|
+
self.stack = None
|
32
34
|
|
33
35
|
|
34
36
|
class RpcSerializer:
|
@@ -121,6 +123,16 @@ class RpcPeer:
|
|
121
123
|
self.killed = False
|
122
124
|
|
123
125
|
def __apply__(self, proxyId: str, oneWayMethods: List[str], method: str, args: list):
|
126
|
+
oneway = oneWayMethods and method in oneWayMethods
|
127
|
+
|
128
|
+
if self.killed:
|
129
|
+
future = Future()
|
130
|
+
if oneway:
|
131
|
+
future.set_result(None)
|
132
|
+
return future
|
133
|
+
future.set_exception(RPCResultError(None, 'RpcPeer has been killed (apply) ' + str(method)))
|
134
|
+
return future
|
135
|
+
|
124
136
|
serializationContext: Dict = {}
|
125
137
|
serializedArgs = []
|
126
138
|
for arg in args:
|
@@ -134,7 +146,7 @@ class RpcPeer:
|
|
134
146
|
'method': method,
|
135
147
|
}
|
136
148
|
|
137
|
-
if
|
149
|
+
if oneway:
|
138
150
|
rpcApply['oneway'] = True
|
139
151
|
self.send(rpcApply, None, serializationContext)
|
140
152
|
future = Future()
|
@@ -472,12 +484,13 @@ class RpcPeer:
|
|
472
484
|
pass
|
473
485
|
|
474
486
|
async def createPendingResult(self, cb: Callable[[str, Callable[[Exception], None]], None]):
|
475
|
-
|
476
|
-
|
487
|
+
future = Future()
|
488
|
+
if self.killed:
|
489
|
+
future.set_exception(RPCResultError(None, 'RpcPeer has been killed (createPendingResult)'))
|
490
|
+
return future
|
477
491
|
|
478
492
|
id = str(self.idCounter)
|
479
493
|
self.idCounter = self.idCounter + 1
|
480
|
-
future = Future()
|
481
494
|
self.pendingResults[id] = future
|
482
495
|
await cb(id, lambda e: future.set_exception(RPCResultError(e, None)))
|
483
496
|
return await future
|