Skip to content
This repository was archived by the owner on Mar 20, 2019. It is now read-only.
This repository was archived by the owner on Mar 20, 2019. It is now read-only.

workaround for having todo_list of length 1 #3

@andreip

Description

@andreip

Hi,
Thanks for the cool library!

I'm wondering what would be the best way to work around the ValueError from the link below if the todo_list say, has a single task. I know that's not really the point behind it (as error says), but just say you want to reuse the code you've written (that uses throuttler.run() inside the loop) to work for several tasks and now want to call it with a single task. What would you do, since you can't just provide per_time_window=len(todo_list)-1 since that'd be 0 -- that was the workaround I had when I supplied less than 100 tasks which is the default time window.

# Safety check.
todo_len = len(todo_list)
if per_time_window >= todo_len:
raise ValueError(("per_time_window should be less than the length "
"of todo_list. Not see much point in throttling "
"if there's no actual throttling."))

To offer more details, the task provided to the throttler also raises ThrottleException to get re-enqueued, so I wouldn't want to just add that Future in the event loop without it being wrapped in a Throttler(...).run() call since it wouldn't know what to do with the ThrottleException.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions