-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththreadedtactic.py
58 lines (42 loc) · 1.24 KB
/
threadedtactic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
sys.path.append(r'D:\talha.ahmed\workspace\pyenv_maya\tactic')
from threading import Thread
import threading
import tactic_client_lib
def make_stub():
return tactic_client_lib.TacticServerStub(login='talha.ahmed',
password="lovethywife", server='tacticvm',
project='captain_khalfan')
class Doer(Thread):
def __init__(self, func, *args):
Thread.__init__(self)
self.func = func
self.args = args
def run(self):
self.func(*self.args)
class Counter(object):
def __init__(self):
self.rlock = threading.RLock()
self.count = 0
def inc(self):
with self.rlock:
self.count += 1
def get(self):
return self.count
count = Counter()
def get_icon_snap(sobject):
stub = make_stub()
snap = stub.get_snapshot(sobject, context='icon')
print sobject['__search_key__'], True if snap else False
count.inc()
stub = make_stub()
objs = stub.query('vfx/asset')
from multiprocessing.pool import ThreadPool
pool = ThreadPool(processes=20)
#pool.map(get_icon_snap, objs)
for obj in objs:
#d=Doer(get_icon_snap, obj)
pool.apply_async(get_icon_snap, args=(obj,))
import time
while(count.get() < len(objs)):
time.sleep(0.1)