Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@multitasking.task
def generate_set(data, process_name, filename):
print("The number of files: ", len(data))
for idx, file in enumerate(data):
if idx % 100 == 0:
print("[{}/{}]".format(idx, len(data) - 1))
'''
try:
img = Image.open(file) # open the image file
img.verify() # verify that it is, in fact, an image
except (IOError, SyntaxError) as e:
if verbosity == 1:
print('Bad file:', file) # print out the names of corrupt files
pass
else:
face_id = os.path.basename(file).split('.')[0]
face_label = os.path.basename(os.path.dirname(file))
@multitasking.task
def hello(count):
sleep = random.randint(1, 10) / 2
print("Hello %s (sleeping for %ss)" % (count, sleep))
time.sleep(sleep)
print("Goodbye %s (after for %ss)" % (count, sleep))
@multitasking.task
def _listen_to_socket(self, subport):
socket = _zmq.Context().socket(_zmq.REP)
socket.bind("tcp://*:%s" % str(subport))
while True:
msg = socket.recv_string()
socket.send_string('[REPLY] %s' % msg)
time.sleep(1)
@multitasking.task
def _list_items_threaded(self, **kwargs):
self.items = self.list_items(**kwargs)
@multitasking.task
def start_cropping(paths, processname):
for path in paths:
if not valid_ext(path.suffix):
print(get_dir_and_file(path), 'is not valid image. Expected extensions: .jpg, .jpeg, .png')
continue
detect_and_store(path, final_dir, args.resize, processname)
print('Process', processname, 'finished!')
@multitasking.task
def write_threaded(self, item, data, metadata={},
npartitions=None, chunksize=None,
overwrite=False, epochdate=False,
reload_items=False, **kwargs):
return self.write(item, data, metadata,
npartitions, chunksize, overwrite,
epochdate, reload_items,
**kwargs)
@multitasking.task
def ibCallback(self, caller, msg, **kwargs):
# on event:
# self.broadcast('kind', 'data')
# self.datastore.save('kind', 'data')
pass