Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Hi All, I Have A Question Regarding

Hi all, I have a question regarding TaskScheduler . When used for scheduling a function, schedule_function , is there a way to pass function arguments? I see in the TaskScheduler class that there is the func_args variable:

def _launch_job_function(self, job, func_args=None):
        # type: (BaseScheduleJob, Optional[Sequence]) -> Optional[Thread]
        # make sure this IS a function job
        if not job.base_function:
            return None

        # check if this is a single instance, then we need to abort the Task
        if job.single_instance and job.get_last_executed_task_id():
            # noinspection PyBroadException
                a_thread = [t for t in enumerate_threads() if t.ident == job.get_last_executed_task_id()]
                if a_thread:
                    a_thread = a_thread[0]
            except Exception:
                a_thread = None

            if a_thread and a_thread.is_alive():
                    "Skipping Task '{}' scheduling, previous Thread instance '{}' still running".format(
                        job.name, a_thread.ident
                return None

        self._log("Scheduling Job '{}', Task '{}' on background thread".format(job.name, job.base_function))
        t = Thread(target=job.base_function, args=func_args or ())
        # mark as run
        return t

Is there a way for me to pass arguments? Something like this:

                       func_args={arg_1:'something', arg_2:'something'},
                       day=1,   # Launch every day
                       hour=6,  # at 6:00 am
Posted one month ago
Votes Newest

Answers 2

@<1634001100262608896:profile|LazyAlligator31> it looks like the args get passed to a python thread. so the should be specified the same way as you would pass them to the args argument in a thread (so a tuple of positional arguments): func_args=("something", "else") . It looks like passing kwargs is not directly supported, but you could build a partial :

from functools import partial
scheduler.add_task(schedule_function=partial(clone_enqueue, arg_1="something", arg_2="else"))
Posted one month ago

Sweet! I'll give that a try. Thank you @<1523701435869433856:profile|SmugDolphin23>

Posted one month ago
2 Answers
one month ago
one month ago