@scrypted/server 0.7.59 → 0.7.61
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 +4 -2
- package/src/media-helpers.ts +7 -0
- package/src/plugin/media.ts +1 -20
- package/src/plugin/mediaobject.ts +22 -0
package/package.json
CHANGED
package/python/plugin_remote.py
CHANGED
@@ -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)
|
@@ -620,7 +623,7 @@ class PluginRemote:
|
|
620
623
|
return
|
621
624
|
|
622
625
|
def stats_runner():
|
623
|
-
ptime = round(time.process_time() * 1000000)
|
626
|
+
ptime = round(time.process_time() * 1000000) + self.ptimeSum
|
624
627
|
try:
|
625
628
|
import psutil
|
626
629
|
process = psutil.Process(os.getpid())
|
@@ -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 = {
|
package/src/media-helpers.ts
CHANGED
package/src/plugin/media.ts
CHANGED
@@ -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
|
+
}
|