@scrypted/server 0.7.59 → 0.7.60

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.59",
3
+ "version": "0.7.60",
4
4
  "description": "",
5
5
  "dependencies": {
6
6
  "@mapbox/node-pre-gyp": "^1.0.10",
@@ -224,6 +224,7 @@ class PluginRemote:
224
224
  mediaManager: MediaManager
225
225
  loop: AbstractEventLoop
226
226
  consoles: Mapping[str, Future[Tuple[StreamReader, StreamWriter]]] = {}
227
+ ptimeSum = 0
227
228
 
228
229
  def __init__(self, peer: rpc.RpcPeer, api, pluginId, hostInfo, loop: AbstractEventLoop):
229
230
  self.allMemoryStats = {}
@@ -522,6 +523,7 @@ class PluginRemote:
522
523
  forkPeer.peerName = 'thread'
523
524
 
524
525
  async def updateStats(stats):
526
+ self.ptimeSum += stats['cpu']['user']
525
527
  self.allMemoryStats[forkPeer] = stats
526
528
  forkPeer.params['updateStats'] = updateStats
527
529
 
@@ -535,6 +537,7 @@ class PluginRemote:
535
537
  self.allMemoryStats.pop(forkPeer)
536
538
  parent_conn.close()
537
539
  rpcTransport.executor.shutdown()
540
+ pluginFork.worker.kill()
538
541
  asyncio.run_coroutine_threadsafe(forkReadLoop(), loop=self.loop)
539
542
  getRemote = await forkPeer.getParam('getRemote')
540
543
  remote: PluginRemote = await getRemote(self.api, self.pluginId, self.hostInfo)
@@ -614,7 +617,7 @@ class PluginRemote:
614
617
  pass
615
618
 
616
619
  async def start_stats_runner(self):
617
- update_stats = await self.peer.getParam('updateStats')
620
+ update_stats = await self.peer.getParam('updateStats') + self.ptimeSum
618
621
  if not update_stats:
619
622
  print('host did not provide update_stats')
620
623
  return
@@ -634,7 +637,6 @@ class PluginRemote:
634
637
  heapTotal = 0
635
638
 
636
639
  for _, stats in self.allMemoryStats.items():
637
- ptime += stats['cpu']['user']
638
640
  heapTotal += stats['memoryUsage']['heapTotal']
639
641
 
640
642
  stats = {
@@ -17,6 +17,13 @@ export function safeKillFFmpeg(cp: ChildProcess) {
17
17
  catch (e) {
18
18
  }
19
19
  setTimeout(() => {
20
+ for (const f of cp.stdio) {
21
+ try {
22
+ f?.destroy();
23
+ }
24
+ catch (e) {
25
+ }
26
+ }
20
27
  cp.kill();
21
28
  setTimeout(() => {
22
29
  cp.kill('SIGKILL');
@@ -9,27 +9,8 @@ import Graph from 'node-dijkstra';
9
9
  import os from 'os';
10
10
  import path from 'path';
11
11
  import MimeType from 'whatwg-mimetype';
12
- import { RpcPeer } from "../rpc";
13
12
  import { MediaObjectRemote } from "./plugin-api";
14
-
15
- class MediaObject implements MediaObjectRemote {
16
- __proxy_props: any;
17
-
18
- constructor(public mimeType: string, public data: any, options: MediaObjectOptions) {
19
- this.__proxy_props = {}
20
- options ||= {};
21
- options.mimeType = mimeType;
22
- for (const [key, value] of Object.entries(options)) {
23
- if (RpcPeer.isTransportSafe(value))
24
- this.__proxy_props[key] = value;
25
- (this as any)[key] = value;
26
- }
27
- }
28
-
29
- async getData(): Promise<Buffer | string> {
30
- return Promise.resolve(this.data);
31
- }
32
- }
13
+ import { MediaObject } from "./mediaobject";
33
14
 
34
15
  function typeMatches(target: string, candidate: string): boolean {
35
16
  // candidate will accept anything
@@ -0,0 +1,22 @@
1
+ import { MediaObjectOptions } from "@scrypted/types";
2
+ import { RpcPeer } from "../rpc";
3
+ import { MediaObjectRemote } from "./plugin-api";
4
+
5
+ export class MediaObject implements MediaObjectRemote {
6
+ __proxy_props: any;
7
+
8
+ constructor(public mimeType: string, public data: any, options: MediaObjectOptions) {
9
+ this.__proxy_props = {}
10
+ options ||= {};
11
+ options.mimeType = mimeType;
12
+ for (const [key, value] of Object.entries(options)) {
13
+ if (RpcPeer.isTransportSafe(value))
14
+ this.__proxy_props[key] = value;
15
+ (this as any)[key] = value;
16
+ }
17
+ }
18
+
19
+ async getData(): Promise<Buffer | string> {
20
+ return Promise.resolve(this.data);
21
+ }
22
+ }