This doesn't work without a.halt() in my example or with a.halt() in
"except" block and I'm not using "while True:"

Gustaw

On 19 Cze, 01:23, Eric Larson <[email protected]> wrote:
> At Fri, 18 Jun 2010 15:10:50 -0700 (PDT),
>
>
>
> Gustaw  wrote:
>
> > How to handle connection problems in Client?
> > For example if server is not started or I have some network problems.
>
> > Example:
>
> > from diesel import Application, Loop, log, Client
> > from diesel.core import ClientConnectionError
>
> > def req_loop():
> >     client = Client()
> >     try:
> >         yield client.connect('127.0.0.1', 2775)
> >     except ClientConnectionError:
> >         log.info( "error1" )
> >     a.halt()
>
> > a = Application()
> > log = log.sublog('client', log.info)
> > a.add_loop(Loop(req_loop))
> > a.run()
>
> Have you tried wrapping the a.halt() in a try/except as well? I've
> found when doing things like while True sometimes having the try/catch
> in the loop doesn't work, but wrapping the entire loop does.
>
> Eric
>
> > does not work and instead of "error1" I see something like this:
>
> > === DIESEL ERROR ===
>
> >  Generator stack at time of error:
>
> > <code object req_loop at 0xb7e5a848, file "http_client.py", line 4>
> > <code object _real_connect at 0xb7c4eba8, file "build/bdist.linux-i686/
> > egg/diesel/client.py", line 84>
>
> >  Standard Traceback:
>
> > Traceback (most recent call last):
> >   File "build/bdist.linux-i686/egg/diesel/core.py", line 244, in
> > cycle_all
> >     item = self.current.throw(*error)
> >   File "build/bdist.linux-i686/egg/diesel/client.py", line 104, in
> > _real_connect
> >     yield cobj
> > ClientConnectionError: [Errno 111] Connection refused
>
> > Regards,
> > Gustaw

Reply via email to