@scrypted/server 0.7.60 → 0.7.62

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrypted/server",
3
- "version": "0.7.60",
3
+ "version": "0.7.62",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@mapbox/node-pre-gyp": "^1.0.10",
@@ -506,9 +506,14 @@ class PluginRemote:
506
506
  print('new fork')
507
507
  pluginFork.worker = multiprocessing.Process(target=plugin_fork, args=(child_conn,), daemon=True)
508
508
  pluginFork.worker.start()
509
+ lastUpdate = time.time()
509
510
 
510
511
  def schedule_exit_check():
511
512
  def exit_check():
513
+ if time.time() - lastUpdate() > 60:
514
+ print('fork worker is unresponsive, terminating')
515
+ pluginFork.worker.kill()
516
+
512
517
  if pluginFork.worker.exitcode != None:
513
518
  pluginFork.worker.join()
514
519
  else:
@@ -523,6 +528,8 @@ class PluginRemote:
523
528
  forkPeer.peerName = 'thread'
524
529
 
525
530
  async def updateStats(stats):
531
+ nonlocal lastUpdate
532
+ lastUpdate = time.time()
526
533
  self.ptimeSum += stats['cpu']['user']
527
534
  self.allMemoryStats[forkPeer] = stats
528
535
  forkPeer.params['updateStats'] = updateStats
@@ -532,8 +539,9 @@ class PluginRemote:
532
539
  await readLoop()
533
540
  except:
534
541
  # traceback.print_exc()
535
- print('fork read loop exited')
542
+ pass
536
543
  finally:
544
+ print('fork read loop exited')
537
545
  self.allMemoryStats.pop(forkPeer)
538
546
  parent_conn.close()
539
547
  rpcTransport.executor.shutdown()
@@ -617,13 +625,13 @@ class PluginRemote:
617
625
  pass
618
626
 
619
627
  async def start_stats_runner(self):
620
- update_stats = await self.peer.getParam('updateStats') + self.ptimeSum
628
+ update_stats = await self.peer.getParam('updateStats')
621
629
  if not update_stats:
622
630
  print('host did not provide update_stats')
623
631
  return
624
632
 
625
633
  def stats_runner():
626
- ptime = round(time.process_time() * 1000000)
634
+ ptime = round(time.process_time() * 1000000) + self.ptimeSum
627
635
  try:
628
636
  import psutil
629
637
  process = psutil.Process(os.getpid())