Re: Freeze and Resume execution

From: Hung Jung Lu (hungjunglu_at_yahoo.com)
Date: 05/20/04


Date: 20 May 2004 13:44:23 -0700


"Miki Tebeka" <miki.tebeka@zoran.com> wrote in message news:<mailman.106.1085054124.6949.python-list@python.org>...
> I'm looking for a way to "yield" an exception.
> ...
> I'd like to use generators but can't see any "nice" way of doing it.
> What I'd like it to throw an exception when the buffer is full and then
> next time the generator is called to continue execution as after a
> "yield".

Generators are yielding in the wrong direction, though.

I will assume that you do not have to roll-back changes. (When there
is a roll-back requirement, things get complicated, and
prototype-based languages are more suitable for that purpose.)

while 1:
    try:
        write_output()
        break
    except BufferFullException:
        request_user_intervention()

Would something like that suit your purpose? (The
request_user_intervention() method could be a callback.)

> Is this possible?
> Can you recommend a good way of doing this? Any state machine?

Yes, of course it's possible. IDEs like VB6 and Visual C++ all have
edit-and-continue features. When a bug happens, the program stops. You
have chance to modify some variables, then resume execution from the
point of failure. Similarly, in transaction-enabled software (like
databases), when failures occur, you can even rollback the whole thing
as if nothing has happened.

It all depends on the details of your requirements. The simplest
solution is the one shown above. If that does not meet your
requirements, could you please post further details?

If you do require roll-back, the solution could be very different.
Prototype-based languages are the natural platform for dealing with
this type of problem. But if you do not use PB-OOP, you will have to
create sandbox objects manually, and do the commitment/roll-back by
hand.

State machines are OK, too. (With a workspace object often known as
REQUEST.) But the problem is how granular you want to define your
states. It's a pain when the level of granularity changes. I'd try the
callback approach shown above, before anything else.

The approach shown above can be further refined upon usage of
aspect-oriented-ish mechanics and/or codeblocks. There are many tools
to attack the problem. It all depends on your specific needs.

regards,

Hung Jung



Relevant Pages

  • Re: yield
    ... When a function contains the "yield" keyword, ... to be a "generator" object. ... In other words, after the function f yields, the function and the execution ... and what global variables are currently ...
    (comp.lang.python)
  • Re: AWR Sample Report
    ... PX Deq: Execute Reply ... AM time period the "PX Deq: Execution Msg" wait event is the top wait ... In previous versions this wait was classified under the "buffer busy ... being read into the buffer cache by another session. ...
    (comp.databases.oracle.server)
  • PEP for nondeterminism.
    ... of nondeterminism as a spring board for future automatic parallelism. ... requirement of sequential execution. ... allowing for a realistic manifestation of a deep generator based ... The semantics of the list comprehension offer the future benefit ...
    (comp.lang.python)
  • [Full-Disclosure] Fwd: [VulnWatch] 5 Windows vulnerabilities for October 2003 (4 critical, 1 importa
    ... Execution ... Buffer Overflow in Windows Troubleshooter ActiveX Control Could Allow Code ...
    (Full-Disclosure)
  • Re: cache invalidate in user space
    ... buffer - which makes content of the D-cache filled by that dummy ... But for future it slows down execution. ... With the PowerPC architecture you have a bunch of cache control instructions ...
    (comp.os.linux.embedded)