[ 
https://issues.apache.org/jira/browse/PROTON-1497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16054013#comment-16054013
 ] 

Jiri Danek commented on PROTON-1497:
------------------------------------

bq. The problem is that if the calculation takes a long time (>1min) to finish, 
randomly the program crashes when trying to execute the send instruction (line 
157).

As a workaround, I'd use two threads. One runs the reactor, the other 
calculates the hashes. I would use a 
https://docs.python.org/2/library/queue.html to pass messages from the reactor 
thread to the processing thread, and another one for the other direction. I 
would use 
https://qpid.apache.org/releases/qpid-proton-0.17.0/proton/python/api/proton.reactor.EventInjector-class.html
 to tell the reactor that there is something to send.

Reading previous paragraph, it sounds absurd to use queues in Python when I 
already have a broker to provide queuing. IMO, there just shouldn't be timeout 
if I take my time in the on_message method. There should be some background 
thread in Proton Python that would keep the session alive for me, without me 
worrying about it.

bq. I also tried to encapsulate the send into a try/except clause, but the code 
inside the except never gets executed.

That makes sense, IMO. Proton Python reactor is event-driven, so exceptions 
won't work. The errors need to be handled in reactor error handler method(s). 
{{on_connection_error}} and so on.

> python program crash on send msg to queue
> -----------------------------------------
>
>                 Key: PROTON-1497
>                 URL: https://issues.apache.org/jira/browse/PROTON-1497
>             Project: Qpid Proton
>          Issue Type: Bug
>          Components: proton-c, python-binding
>    Affects Versions: 0.17.0
>         Environment: redhat 7.2 - activemq-5.14.3 - Python 3.6.0
>            Reporter: Pier Paolo Panto
>         Attachments: md5.py
>
>
> In the attached file there is an on_message method that performs a lenghty 
> calculation whenever a message is receivede on the input queue. In this case, 
> the branch that gets executed is the one starting at line 123. 
> A the end of the branch a new message is created and sent so an out queue.
> The problem is that if the calculation takes a long time (>1min) to finish, 
> randomly the program crashes when trying to execute the send instruction 
>  (line 157). I also tryed to encapsulate the send into a try/except clause, 
> but the code inside the except never gets executed. 
> Moreover, the exit code (echo $?) when the program crashes is 0
> When this happens, I get this message in the log file:
> handlers.py:234 in print_error(): local-idle-timeout expired
> but setting the timeout parameters for the connection has no effect.
> What could be causing this behaviour?
> Best Regard,
> PPP



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to