question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expiring a mostly-finished task run.

See original GitHub issue

If I have a large task run, expiring it expires all its units, which sets the expiry on mturk even if the unit is completed. This can take a long time. I am wondering if this is worth optimizing. If so, would the following change in mephisto, in mturk_unit.py, be safe?

     def expire(self) -> float:
         """
         Send a request to expire the HIT, and if it's not assigned return,
         otherwise just return the maximum assignment duration
         """
         delay = 0

+        status = self.get_status()
+        if status in [AssignmentState.EXPIRED, AssignmentState.COMPLETED]:
+            return delay

-        if self.get_status() == AssignmentState.ASSIGNED:
+        if status == AssignmentState.ASSIGNED:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JackUrbcommented, Jun 17, 2021

@federicoruggeri this is something of a bug in behavior, but not of intent. When an agent disconnects, if the system doesn’t explicitly expire the Unit, we assume that the Unit should be put up for a different agent to be able to accept. In the case of a dialogue task though, we do expire the Unit directly, but then the get_status overrides that. We should reject the edge transition to LAUNCHED here though specifically if the unit is already in the expired state: https://github.com/facebookresearch/Mephisto/blob/fc359c74dc73c4c408b089301833682107bbbbfa/mephisto/data_model/unit.py#L285-L289

Good job in identifying the logical transition though, this fix would definitely be appreciated.

1reaction
bottlercommented, Apr 21, 2021

I’ve been testing this out, running large runs for a few days, and it seems to be working. I will make a PR.

There are often cases where I expire a run* and wait a while (much longer than the assignment duration) and find that there’s a hit or two in the “launched” state. In this case, expiring the run again succeeds in cleaning up.

  • i.e. operator.get_running_task_runs()[...].task_launcher.expire_units()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Asynchronously wait for Task<T> to complete with timeout
Delay task is backed by a system timer which will continue to be tracked until the timeout expires regardless of how long SomeOperationAsync...
Read more >
Just because you stopped waiting for it, doesn't mean the Task ...
Without special handling, a Task always run to completion. Let's start by looking at what happens to the "source" Task when you use...
Read more >
Running an async task with a timeout - Swift Forums
Its goal is to run an async task with a timeout. If the timeout expires and the work hasn't completed, it should cancel...
Read more >
The danger of TaskCompletionSource class
It means that an “async” continuation runs synchronously almost all the time when the awaited task is not finished!
Read more >
Tasks - Prefect 2 - Coordinating the world's dataflows
Caching refers to the ability of a task run to reflect a finished state without ... results are used rather than running the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found