Retry Module

class judge0.retry.RetryStrategy

Abstract base class that defines the interface for any retry strategy.

See MaxRetries, MaxWaitTime, and RegularPeriodRetry for example implementations.

abstract is_done()

Check if the retry strategy has exhausted its retries.

Return type:

bool

abstract wait()

Delay implementation before the next retry attempt.

Return type:

None

abstract step()

Update internal attributes of the retry strategy.

Return type:

None

class judge0.retry.MaxRetries(max_retries=20)

Check for submissions status every 100 ms and retry a maximum of max_retries times.

Parameters:

max_retries (int) – Max number of retries.

step()

Increment the number of retries by one.

wait()

Wait for 0.1 seconds between retries.

is_done()

Check if the number of retries is bigger or equal to specified maximum number of retries.

Return type:

bool

class judge0.retry.MaxWaitTime(max_wait_time_sec=300)

Check for submissions status every 100 ms and wait for all submissions a maximum of max_wait_time (seconds).

Parameters:

max_wait_time_sec (float) – Maximum waiting time (in seconds).

step()

Add 0.1 seconds to total waiting time.

wait()

Wait (sleep) for 0.1 seconds.

is_done()

Check if the total waiting time is bigger or equal to the specified maximum waiting time.

class judge0.retry.RegularPeriodRetry(wait_time_sec=0.1)

Check for submissions status periodically for indefinite amount of time.

Parameters:

wait_time_sec (float) – Wait time between retries (in seconds).

wait()

Wait for wait_time_sec seconds.

is_done()

Return False, as this retry strategy is indefinite.

Return type:

bool

step()

Satisfy the interface with a dummy implementation.

Return type:

None