pypipr 1.0.84__py3-none-any.whl → 1.0.85__py3-none-any.whl
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.
- pypipr/__init__.py +3 -0
- pypipr/ibuiltins/RunParallel.py +58 -1
- pypipr/ifunctions/iscandir.py +2 -4
- {pypipr-1.0.84.dist-info → pypipr-1.0.85.dist-info}/METADATA +1066 -1060
- {pypipr-1.0.84.dist-info → pypipr-1.0.85.dist-info}/RECORD +7 -7
- {pypipr-1.0.84.dist-info → pypipr-1.0.85.dist-info}/WHEEL +0 -0
- {pypipr-1.0.84.dist-info → pypipr-1.0.85.dist-info}/entry_points.txt +0 -0
pypipr/__init__.py
CHANGED
@@ -62,6 +62,7 @@ from .ifunctions.irange import irange
|
|
62
62
|
from .ifunctions.ireplace import ireplace
|
63
63
|
from .ifunctions.iscandir import iscandir
|
64
64
|
from .ifunctions.isplit import isplit
|
65
|
+
import asyncio
|
65
66
|
import colorama
|
66
67
|
import datetime
|
67
68
|
import functools
|
@@ -70,6 +71,7 @@ import io
|
|
70
71
|
import json
|
71
72
|
import lxml
|
72
73
|
import math
|
74
|
+
import multiprocessing
|
73
75
|
import operator
|
74
76
|
import os
|
75
77
|
import pathlib
|
@@ -83,6 +85,7 @@ import string
|
|
83
85
|
import subprocess
|
84
86
|
import sys
|
85
87
|
import textwrap
|
88
|
+
import threading
|
86
89
|
import time
|
87
90
|
import tzdata
|
88
91
|
import uuid
|
pypipr/ibuiltins/RunParallel.py
CHANGED
@@ -47,7 +47,7 @@ class RunParallel:
|
|
47
47
|
Akses resource menggunakan parameter yang sudah disediakan yaitu
|
48
48
|
`result: dict` dan `q: queue.Queue`.
|
49
49
|
|
50
|
-
```
|
50
|
+
```py
|
51
51
|
class ExampleRunParallel(RunParallel):
|
52
52
|
z = "ini"
|
53
53
|
|
@@ -165,3 +165,60 @@ class RunParallel:
|
|
165
165
|
for i in r:
|
166
166
|
i.join()
|
167
167
|
return (i.copy() for i in a)
|
168
|
+
|
169
|
+
|
170
|
+
class ExampleRunParallel(RunParallel):
|
171
|
+
z = "ini"
|
172
|
+
|
173
|
+
def __init__(self) -> None:
|
174
|
+
self.pop = random.randint(0, 100)
|
175
|
+
|
176
|
+
def _set_property_here(self, v):
|
177
|
+
self.prop = v
|
178
|
+
|
179
|
+
def a(self, result: dict, q: queue.Queue):
|
180
|
+
result["z"] = self.z
|
181
|
+
result["pop"] = self.pop
|
182
|
+
result["a"] = "a"
|
183
|
+
q.put("from a 1")
|
184
|
+
q.put("from a 2")
|
185
|
+
|
186
|
+
def b(self, result: dict, q: queue.Queue):
|
187
|
+
result["z"] = self.z
|
188
|
+
result["pop"] = self.pop
|
189
|
+
result["b"] = "b"
|
190
|
+
result["q_get"] = q.get()
|
191
|
+
|
192
|
+
def c(self, result: dict, q: queue.Queue):
|
193
|
+
result["z"] = self.z
|
194
|
+
result["pop"] = self.pop
|
195
|
+
result["c"] = "c"
|
196
|
+
result["q_get"] = q.get()
|
197
|
+
|
198
|
+
async def d(self):
|
199
|
+
print("hello")
|
200
|
+
await asyncio.sleep(0)
|
201
|
+
print("hello")
|
202
|
+
|
203
|
+
result = {}
|
204
|
+
result["z"] = self.z
|
205
|
+
result["pop"] = self.pop
|
206
|
+
result["d"] = "d"
|
207
|
+
return result
|
208
|
+
|
209
|
+
async def e(self):
|
210
|
+
print("world")
|
211
|
+
await asyncio.sleep(0)
|
212
|
+
print("world")
|
213
|
+
|
214
|
+
result = {}
|
215
|
+
result["z"] = self.z
|
216
|
+
result["pop"] = self.pop
|
217
|
+
result["e"] = "e"
|
218
|
+
return result
|
219
|
+
|
220
|
+
|
221
|
+
if __name__ == "__main__":
|
222
|
+
print(ExampleRunParallel().run_asyncio())
|
223
|
+
print(ExampleRunParallel().run_multi_threading())
|
224
|
+
print(ExampleRunParallel().run_multi_processing())
|
pypipr/ifunctions/iscandir.py
CHANGED