Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Source starkit-wrapped files from a thread

35 views
Skip to first unread message

Rolf Schroedter

unread,
Nov 27, 2017, 2:07:16 AM11/27/17
to
I am unable to source starkit-wrapped TCL-files from inside a thread.
Is there such a limitation ?
That would also mean a thread cannot [packet require] if the package is
wrapped ...

Any help is appreciated.
Regards, Rolf

Eric

unread,
Nov 27, 2017, 2:59:57 AM11/27/17
to
Le lundi 27 novembre 2017 08:07:16 UTC+1, Rolf Schroedter a écrit :
> I am unable to source starkit-wrapped TCL-files from inside a thread.
> Is there such a limitation ?
> That would also mean a thread cannot [packet require] if the package is
> wrapped ...

Hi Rolf,

I had the same problem when loading starkit in several interp.
I have modified the "header" proc in tclvfs starkit.tcl as follow:

# called from the header of a starkit
proc header {driver args} {
if {[catch {
set self [fullnormalize [info script]]

package require vfs::${driver}
# Don't use mounted file as mount point, otherwise it can't be sourced anymore
# because not considered as native file.
# Also, mount file only once.
set mntpoint "$self@vfs"
if {![file exists $mntpoint]} {
::vfs::${driver}::Mount $self $mntpoint {*}$args
}
uplevel [list source [file join $mntpoint main.tcl]]
}]} {
panic $::errorInfo
}
}

Take care that I had to change the mount point, which may lead to problems in your own code if it depends on it.
Don't know if it will fix the problem in different thread, but you can try.

Eric

Rolf Schroedter

unread,
Nov 27, 2017, 8:47:59 AM11/27/17
to

Rolf Schroedter

unread,
Nov 27, 2017, 8:49:05 AM11/27/17
to
On 27.11.2017 08:59, Eric wrote:
Thank you Eric,
so I am not alone with this problem.

My workaround for sourcing is to read the entire scripts from the
wrapped sources into the main thread and let the other thread execute
the script. Something like:

set tid [thread::create {thread::wait}]

foreach filename $my_list_of_wrapped_files_for_thread } {
set f [open $filename r]
set script [read $f]
close $f

thread::send $tid $script
}

However this doesn't solve the problem of wrapped TCL packages thread.
Rolf


0 new messages