nailgun icon indicating copy to clipboard operation
nailgun copied to clipboard

Make timeouts configurable on a per-call basis

Open Ichimonji10 opened this issue 9 years ago • 4 comments

Many calls require that you wait for a task to complete. For example, publishing a content view or syncing a repository takes a non-trivial amount of time, and a foreman task is created to track the progress of said tasks. Different types of calls require different timeouts. For example, publishing a content view might complete in just a few minutes, whereas syncing a repository may take several hours. It'd be nice to be able to control the timeout.

We can currently do this via the module-wide nailgun.entity_mixins.TASK_TIMEOUT variable. It's currently set to a default of 300 (seconds). It's possible to fiddle with this setting, but using this setting is extremely threading-unfriendly. What happens if two different threads adust the timeout to different values, and then restore the timeout later on?

A better approach would be to let the timeout be specified on a per-call basis. In the immediate future, we can add a timeout kwarg to all of the helper methods. Here are some examples of usage:

repository.sync(timeout=3600)
content_view.publish(timeout=300)

Ichimonji10 avatar Sep 15 '15 20:09 Ichimonji10

:+1:

elyezer avatar Sep 24 '15 18:09 elyezer

:+1:

sthirugn avatar Sep 25 '15 20:09 sthirugn

I am planning to work on this.

support some of the approaches:

context manager (the easiest to implement)

A general Context manager to configure nalgun global variables

from nailgun import Context
with Context(timeout=3600):
    repository.sync()

A method in entities

rep = Repository.with_(timeout=3600).create(....)

A explicit arg on call

repository.sync(timeout=3600)

rochacbruno avatar Sep 28 '16 15:09 rochacbruno

I like option 1 and 3.

elyezer avatar Sep 28 '16 16:09 elyezer