Deepanshu wrote:
> Hi,
>
> I am looking to run a couple of processes in parallel. But a
> strange hang occurs randomly. I am invoking two tcl commands
> using open in parallel. Now after a while one of the process
> would just hang indefinitely which I am not able to understand
> why. The issue is easily reproducible on win 2008 server and
> other multi core machines. Am I doing something wrongly? What is
> the best way to do this?
>
[snip]
>
> Please help.
>
> TIA.
> Deepanshu
I don't use windows myself and therefor I didn't run your code, but
I can see a number of issues with it. First of all you appear to be
confused about fileevents. The code you posted doesn't actually use
them, so you are not doing anything in parallel at all.
The fileevent commands takes a script that will be executed when
data becomes available on the channel. Your code just reads the
channel until it reaches eof and then passes that as the script
argument to the fileevent command. It then does the same thing for
the second command. So completely serial.
The reason the strange fileevent script doesn't result in an error
is that you never enter the event loop, so the fileevent doesn't get
a chance to fire.
To use fileevents effectively you should also make your channels
non-blocking.
I don't know if fixing these issues will avoid the hang, but at
least it should make your code do something closer to what you think
it is doing.
Schelte.