From: Jens Benner on
Hi all,

I tried to enhance an existing Application with an Tcl interpreter. This
Application starts several thread to parse some different files. The
threading is done by win32 mechanism.

In every thread id do the following things:

// On thread Startup
TclInterp = Tcl_CreateInterp();
Tcl_FindExecutable(NULL);
Tcl_CreateCommand(TclInterp, "myCallback", TclCallbackCmd,
(ClientData)this, (Tcl_CmdDeleteProc*) NULL);
Tcl_EvalFile(TclInterp, "MySript.tcl");


....

//Pass some data and do some work
while ( ... ) {

Tcl_Eval(TclInterp, "myCommad param1 param2");

}

....

// On thread shutdown
Tcl_DeleteCommand(TclInterp, "myCallback");
Tcl_DeleteInterp(TclInterp);



This runs fine so far for a lot of cycles but it randomly hangs up after
several hours or days. A closer look with the debugger shows, that it
hangs at the line TclInterp = Tcl_CreateInterp();

Is there may be something I forgot, or something I'm doing wrong?
Do I have to call Tcl_Finalize() after Tcl_DeleteInterp()?

Thanks in advance.
Jens

From: Christian Nassau on
Jens Benner wrote:
> In every thread id do the following things:
>
> // On thread Startup
> TclInterp = Tcl_CreateInterp();
> Tcl_FindExecutable(NULL);
> Tcl_CreateCommand(TclInterp, "myCallback", TclCallbackCmd,
> (ClientData)this, (Tcl_CmdDeleteProc*) NULL);
> Tcl_EvalFile(TclInterp, "MySript.tcl");
> ...

The purpose of "Tcl_FindExecutable(NULL);" is to initialize all of the
subsystems that the other Tcl calls rely on. You should therefore call
it *only once* when your application starts, and *before* any worker
thread is spawned.

Apart from that your setup looks fine to me.

HTH,

--
=> Christian Nassau, http://www.nullhomotopie.de


From: Don Porter on
Jens Benner wrote:
> This runs fine so far for a lot of cycles but it randomly hangs up after
> several hours or days. A closer look with the debugger shows, that it
> hangs at the line TclInterp = Tcl_CreateInterp();

It might make more sense to debug this via the Tracker at Tcl's
SourceForge project. Meanwhile, precisely what release of Tcl
shows the trouble you report?

--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter(a)nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
From: Jens Benner on
Don Porter schrieb:
> Jens Benner wrote:
>> This runs fine so far for a lot of cycles but it randomly hangs up after
>> several hours or days. A closer look with the debugger shows, that it
>> hangs at the line TclInterp = Tcl_CreateInterp();
>
> It might make more sense to debug this via the Tracker at Tcl's
> SourceForge project. Meanwhile, precisely what release of Tcl
> shows the trouble you report?
>

Thanks a lot for your help Don,

I'm using Tcl 8.4.2 and I linked against tcl84t.lib/tcl84t.dll

Regards
Jens
From: Jens Benner on
Christian Nassau schrieb:
> Jens Benner wrote:
>> In every thread id do the following things:
>>
>> // On thread Startup
>> TclInterp = Tcl_CreateInterp();
>> Tcl_FindExecutable(NULL);
>> Tcl_CreateCommand(TclInterp, "myCallback", TclCallbackCmd,
>> (ClientData)this, (Tcl_CmdDeleteProc*) NULL);
>> Tcl_EvalFile(TclInterp, "MySript.tcl");
>> ...
>
> The purpose of "Tcl_FindExecutable(NULL);" is to initialize all of the
> subsystems that the other Tcl calls rely on. You should therefore call
> it *only once* when your application starts, and *before* any worker
> thread is spawned.
>
> Apart from that your setup looks fine to me.
>
> HTH,
>

Hello Christian,

the application loads a lot of modules (dlls) via dynamically via
loadlibrary(). In one of these modules I integrated the Tcl interpreter.
So only this module is linked against tcl84t.lib/tcl84t.dll. The Module
is unloaded after work and loaded again if there is work to do.
So do I have to call Tcl_FindExecutable(NULL) every time the module is
loaded? Or do I have to link the complete Application to Tcl and call
Tcl_FindExecutable(NULL) at application Startup?
Is there a way to detect if Tcl_FindExecutable(NULL) was already called
or has to be called again?

Thanks
Jens
 |  Next  |  Last
Pages: 1 2
Prev: send command in expect
Next: working with oracle clob