Re: Running a threaded Tk script on Windows
by Errto (Vicar) on Sep 15, 2005 at 19:52 UTC
|
One issue might be the fact that you've loaded Tk, which is an XS module, and then spawned threads, which attempts to duplicate the data (even though you only use the Tk objects from one of the threads). The way around this is to replace your use Tk and use Tk::Something statements with require statements and place these after the point in the code where you launch your threads.
Update: to give proper credit, I got this idea from BrowserUk in a node I can't find but it might have been this one.
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
Thanks for the ideas. But I do spawn the threads before I start any Tk code, and it does run fine on linux.
Just because it works on linux doesn't mean its supposed to :)
and the mere act of useing the module executes code.
From perlthrtut
If you're using a module that's not thread-safe for some reason, you can protect yourself by using it from one, and only one thread at all. If you need multiple threads to access such a module, you can use semaphores and lots of programming discipline to control access to it.
Tk is not thread-safe.
| MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] |
|
|
|
|
|
Re: Running a threaded Tk script on Windows
by renodino (Curate) on Sep 16, 2005 at 16:50 UTC
|
You failed mention which version of Perl you were using
on Win32 ?
FYI: This is one of the issues I'm trying to address w/
Thread::Apartment
(see also Apartment Threading in Perl), if I ever manage to get the
proxied closure business figured out...
Also, does this tool have the ability
to display just specific categories of programs
(in my case, sports ?) I've been dealing with various
online tvguides for that purpose over the years w/
limited success.
| [reply] |
|
|
| [reply] |
|
|
I've actually had better threads success w/ 5.8.6 on Win32 (XP to be precise); 5.8.7 occasionally throws some odd errors
out of threads::shared. At least, thats been the
case while testing DBIx::Threaded, Thread::Queue::Duplex,
and Thread::Apartment.
As an independent test of a similar environment, you might want to try installing DBIx::Threaded
and testing with DBD::SQLite, as it has many of the same
issues as Perl/Tk (ie, lots of XS code, not threadsafe, but can be run inside its own thread). If it coughs, it might be a problem with your configuration or WinME (I've never used
the latter w/ Perl threads, only WinXP or 2K).
| [reply] |
|
|
Hi again, i did get my basic thread model to finally run on windows, the code is below. My tvguide code still fails, but I really don't think it's Tk. It must be something else, and I guess I will have to manually rebuild the entire code from scratch on windows, testing at each step, to see what causes it to fail. It looks like I can get it to work, with an afternoon of fiddling with it. :-)
I'm not really a human, but I play one on earth.
flash japh
| [reply] [d/l] |
Re: Running a threaded Tk script on Windows
by zentara (Cardinal) on Sep 16, 2005 at 21:38 UTC
|
Well, I found what the "glitch" was. It wasn't Tk. I declared some shared variables in a deep hash for about 1800 entries.
my %days;
my @chs = qw (1..30);
my $max_prog_chan = 60;
foreach my $channel(@chs){
foreach my $count(0..$max_prog_chan){
share $days{$channel}{$count}{'channel'};
share $days{$channel}{$count}{'channel_info'};
share $days{$channel}{$count}{'episode_num'};
share $days{$channel}{$count}{'start'};
share $days{$channel}{$count}{'stop'};
share $days{$channel}{$count}{'makedate'};
share $days{$channel}{$count}{'description'};
share $days{$channel}{$count}{'title'};
share $days{$channel}{$count}{'writer'};
share $days{$channel}{$count}{'director'};
share $days{$channel}{$count}{'actors'};
share $days{$channel}{$count}{'rating'};
share $days{$channel}{$count}{'length'};
share $days{$channel}{$count}{'category'};
share $days{$channel}{$count}{'star_rating'};
}
}
That just bogged down things on WindowsMe, but linux just
whizzed thru it. I changed it to the following and got things to
go ( for the most part).
my %days;
my @chs = qw (1..30);
my $max_prog_chan = 60;
foreach my $channel(@chs){
foreach my $count(0..$max_prog_chan){
share $days{$channel}{$count};
}
}
So it seems Windows didn't like all those explicitly named shared assignments.
I'm not really a human, but I play one on earth.
flash japh
| [reply] [d/l] [select] |