Bug #1053 (closed)
Session.timeToLive representation does not work in Python
| Reported by: | jamoore | Owned by: | jamoore |
|---|---|---|---|
| Priority: | minor | Cc: | cxallan, atarkowska, cblackburn |
| Sprint: | n.a. | ||
| Total Remaining Time: | n.a. |
Description
Currently timeToLive represents the number of milliseconds after session creation (started, in milliseconds since the epoch) which a session can still be accessed, or:
if (currentTime > sessionCreation + timeToLive) {
removeSession();
}
Currently, sessions (specifically OmeroShares) which are to persist forever, are given a value of:
Long.MAX_VALUE - sessionCreation
so that:
long time = System.currentTimeMillis();
long max = Long.MAX_VALUE;
System.out.println(max - time);
System.out.println(new Timestamp(max - time));
produces
9223370818800686547 292278956-01-11 11:51:26.547
When this value is transported to other systems, like python, the time libraries are unhappy:
time.ctime(creationTime/1000+t ) timestamp out of range for platform time_t
making display difficult.
Change History (6)
comment:1 Changed 11 years ago by jmoore
comment:2 Changed 11 years ago by jmoore
Ola, what are your thoughts on this?
comment:3 Changed 11 years ago by cblackburn
Is it feasible to use a third-party library such as,
comment:4 Changed 11 years ago by jmoore
- Cc cblackburn added
- Resolution set to fixed
- Status changed from new to closed
Colin, thanks for the link. The mx library looks interesting; in addition to the date/time bits, mxBeeBase and mxUID among others could be useful. Do you think this is something we should package? Have you used it in anger?
Anyway, I think for the moment we'll consider the server's definition of timeToLive (even if it should be in seconds and not milliseconds) definitive and find a way to work around in the other languages. If this proves impossible, we can re-evaluate.
comment:5 Changed 11 years ago by cxallan
- Version 3.0-M1 deleted
FWIW, I use mx extensively in my side projects. It's particularly nice for working with date's and time's and is a stable, well documented and well written library.
comment:6 Changed 11 years ago by jmoore
Good to hear. The major problem would be the native code. But I think that's going to be something we have to tackle one way or the other.
I'd prefer not to use a negative value to represent "the end of time", since doing math on that can make for very strange results. It would be an option to choose as the maximum value 2038 (the maximum value in Python), but I *hope* OMERO actually runs that long. Would it be possible, Ola, to catch the ValueError and simply display: "No expiration"?