@scrypted/server 0.7.11 → 0.7.13
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/plugin_remote.py +16 -2
package/package.json
CHANGED
package/python/plugin_remote.py
CHANGED
@@ -44,7 +44,7 @@ class StreamPipeReader:
|
|
44
44
|
def readBlocking(self, n):
|
45
45
|
b = bytes(0)
|
46
46
|
while len(b) < n:
|
47
|
-
self.conn.poll()
|
47
|
+
self.conn.poll(None)
|
48
48
|
add = os.read(self.conn.fileno(), n - len(b))
|
49
49
|
if not len(add):
|
50
50
|
raise Exception('unable to read requested bytes')
|
@@ -488,6 +488,11 @@ class PluginRemote:
|
|
488
488
|
reader = StreamPipeReader(parent_conn)
|
489
489
|
forkPeer, readLoop = await rpc_reader.prepare_peer_readloop(self.loop, reader = reader, writeFd = parent_conn.fileno())
|
490
490
|
forkPeer.peerName = 'thread'
|
491
|
+
|
492
|
+
async def updateStats(stats):
|
493
|
+
allMemoryStats[forkPeer] = stats
|
494
|
+
forkPeer.params['updateStats'] = updateStats
|
495
|
+
|
491
496
|
async def forkReadLoop():
|
492
497
|
try:
|
493
498
|
await readLoop()
|
@@ -495,6 +500,7 @@ class PluginRemote:
|
|
495
500
|
# traceback.print_exc()
|
496
501
|
print('fork read loop exited')
|
497
502
|
finally:
|
503
|
+
allMemoryStats.pop(forkPeer)
|
498
504
|
parent_conn.close()
|
499
505
|
reader.executor.shutdown()
|
500
506
|
asyncio.run_coroutine_threadsafe(forkReadLoop(), loop=self.loop)
|
@@ -585,6 +591,9 @@ class PluginRemote:
|
|
585
591
|
async def getServicePort(self, name):
|
586
592
|
pass
|
587
593
|
|
594
|
+
|
595
|
+
allMemoryStats = {}
|
596
|
+
|
588
597
|
async def plugin_async_main(loop: AbstractEventLoop, readFd: int = None, writeFd: int = None, reader: asyncio.StreamReader = None, writer: asyncio.StreamWriter = None):
|
589
598
|
peer, readLoop = await rpc_reader.prepare_peer_readloop(loop, readFd=readFd, writeFd=writeFd, reader=reader, writer=writer)
|
590
599
|
peer.params['print'] = print
|
@@ -593,6 +602,7 @@ async def plugin_async_main(loop: AbstractEventLoop, readFd: int = None, writeFd
|
|
593
602
|
async def get_update_stats():
|
594
603
|
update_stats = await peer.getParam('updateStats')
|
595
604
|
if not update_stats:
|
605
|
+
print('host did not provide update_stats')
|
596
606
|
return
|
597
607
|
|
598
608
|
def stats_runner():
|
@@ -608,8 +618,12 @@ async def plugin_async_main(loop: AbstractEventLoop, readFd: int = None, writeFd
|
|
608
618
|
resource.RUSAGE_SELF).ru_maxrss
|
609
619
|
except:
|
610
620
|
heapTotal = 0
|
621
|
+
|
622
|
+
for _, stats in allMemoryStats.items():
|
623
|
+
ptime += stats['cpu']['user']
|
624
|
+
heapTotal += stats['memoryUsage']['heapTotal']
|
625
|
+
|
611
626
|
stats = {
|
612
|
-
'type': 'stats',
|
613
627
|
'cpu': {
|
614
628
|
'user': ptime,
|
615
629
|
'system': 0,
|