How to use the multitasking.task function in multitasking

To help you get started, we’ve selected a few multitasking examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tbmoon / facenet / datasets / write_csv_for_making_dataset.py View on Github external
@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))
github ranaroussi / multitasking / example.py View on Github external
@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))
github ranaroussi / qtpylib / qtpylib / blotters / base.py View on Github external
    @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)
github ranaroussi / pystore / pystore / collection.py View on Github external
    @multitasking.task
    def _list_items_threaded(self, **kwargs):
        self.items = self.list_items(**kwargs)
github tbmoon / facenet / mtcnn.py View on Github external
@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!')
github ranaroussi / pystore / pystore / collection.py View on Github external
    @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)
github ranaroussi / qtpylib / qtpylib / blotters / ibgw.py View on Github external
    @multitasking.task
    def ibCallback(self, caller, msg, **kwargs):

        # on event:
        # self.broadcast('kind', 'data')
        # self.datastore.save('kind', 'data')

        pass

multitasking

Non-blocking Python methods using decorators

Apache-2.0
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis

Popular multitasking functions