-
Notifications
You must be signed in to change notification settings - Fork 61
Make an atomic context manager #13
Comments
Original comment by RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew): @krisvale on 2013-01-30 12:01:01 said: There is one in stacklesslib.util It´s like this:
The only thing that is annoying is that a local instance is required to hold the previous value.
and then:
A stateless context manager has performance benefits. |
Original comment by RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew): @krisvale on 2013-01-30 12:54:40 said: A context manager can be stateless.
There are other exapmples of useful singleton context managers, such as context managers that translate exceptions but otherwise need not hold on to any data in self. |
Original comment by RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew): @ctismer on 2013-01-30 12:46:34 said: The generator based implementation is very ok, IMHO. Of course it might be more efficient to avoid the creation of an object. Did you mean that? Maybe this can be optimized quite much: I think the atomic feature always makes only
and you even avoid the atomic() call? |
Original comment by RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew): @ctismer on 2013-01-30 13:20:27 said: Yes, I understand. No state in self, but state elsewhere, in this case a counter in the tasklet. But we are on the same track, using a singleton to use for the with, and this singleton needs to be created A completely different approach: |
Original comment by RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew): @ctismer on 2013-01-30 16:16:38 said: On list/dict/set: I meant a list of lists/dict/set with the list index as the nesting level. On atomic state: The reason why I had that flag in the tasklet was my uncertaincy concerning a tasklet In addition to the local |
Original comment by RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew): @krisvale on 2013-01-30 14:38:14 said: Yes, but I would consider this an implementation detail. Although having a stackless module level function rather than a tasklet function to affect this is appealing. One should only ever modify one's own 'atomic' state. stackless.inc_atomic() Also, implementation wise, if you decide to have a global list or dict, it still needs to cope with the concept of "level" in order to cope with nested usage of 'atomic'. |
Original comment by Anonymous: this has been done already in
at 2013-08-28 by Kristjan Valur Johnsson |
If the IRC notification is stored in plaintext, then anyone who forks the repository and also adds it to travis will send notifications to the IRC channel for their fork by default. Since the secure variable is encrypted using a repository specific key, this will only work when it is being built using the correct repository.
Originally reported by: RMTEW FULL NAME (Bitbucket: rmtew, GitHub: rmtew)
(originally reported in Trac by @ctismer on 2013-01-27 03:16:39)
Thinking of this example of atomic (taken as-is)
I felt it would make sense to make a context manager:
See http://www.python.org/dev/peps/pep-0343/
What do you think:
Does the syntax make sense, or is there a usecase that operates on anything else than
//stackless.getcurrent()//?
The text was updated successfully, but these errors were encountered: