source: geniuswebcore/geniusweb/progress/Progress.py

Last change on this file was 100, checked in by ruud, 20 months ago

python installs also wheel to avoid error messages

File size: 1.9 KB
Line 
1from abc import ABC, abstractmethod
2from datetime import datetime
3from pyson.JsonSubTypes import JsonSubTypes
4from pyson.JsonTypeInfo import JsonTypeInfo, Id, As
5
6@JsonTypeInfo(use = Id.NAME, include = As.WRAPPER_OBJECT)
7@JsonSubTypes([ "geniusweb.progress.ProgressTime.ProgressTime", "geniusweb.progress.ProgressRounds.ProgressRounds"] )
8class Progress(ABC):
9 '''
10 Progress is similar to {@link Deadline} but contains absolute values. It
11 always contains a hard termination moment at which the party should be
12 killed. This is used to free up the run server. The protocol should always
13 check its own clock, as parties may be ignoring or cheating with the
14 deadline.
15 <p>
16 immutable.
17
18 '''
19 @abstractmethod
20 def get(self,currentTimeMs:int)->float:
21 '''
22 @param currentTimeMs the current time in ms since 1970 as from
23 {@link System#currentTimeMillis()}.
24 @return the current time as a fraction of the total amount of time/rounds
25 available. So at start this returns 0, and when (and after) the
26 deadline is reached this returns 1. Notice that when the progress
27 is about the number of rounds, the party may also want to keep an
28 eye on {@link #getTerminationTime()}.
29 '''
30
31 @abstractmethod
32 def getTerminationTime(self)->datetime :
33 '''
34 @return the unix time (UTC, ms since 1970) at which the party will be
35 terminated. At this time the server can remove the party and free
36 up its resources. Notice that server and party implementations
37 are free to ignore this, the protocol should always check on
38 whether a party is out of time.
39 '''
40
41 @abstractmethod
42 def isPastDeadline(self, currentTimeMs:int) -> bool:
43 '''
44 @param currentTimeMs the current time in ms since 1970 as from
45 {@link System#currentTimeMillis()}.
46 @return true iff the progress has passed the deadline.
47 '''
Note: See TracBrowser for help on using the repository browser.