cristiklein / simpy

MIT License
107 stars 16 forks source link

Why `yield env.process(Timeout(self.env, delay)) is not working? #9

Closed arisliang closed 4 years ago

arisliang commented 4 years ago

For a newbie (I'm just going through the Tropical guide "Waiting for another process to terminate"), I imagined yield self.env.process(Timeout(self.env, delay)) and yield self.env.timeout(delay) is equivalent expression, where the latter is a short form of the former, because both expression have the same meaning to register the Timeout event with the environment, and get triggered a later time.

But former complains ValueError: <Timeout(29) object at 0x2997fa2fd08> is not a generator..

The generator in the error indicates, there's something technical going on, could you please shed some light on what is the difference of these two forms? And how to make the former work (that is to use Timeout directly) if desired to for testing purpose?

arisliang commented 4 years ago

Managed to use the Timeout work directly with yield Timeout(self.env, delay). I was thinking over complicated about it.