[prev in list] [next in list] [prev in thread] [next in thread]
List: perl-win32-users
Subject: RE: Win32:OLE - Threadsafe?
From: "Neil Burnett" <neil () efc ! be>
Date: 2005-02-28 19:56:46
Message-ID: 20050228195647.2B35D3BC1BE () poros ! telenet-ops ! be
[Download RAW message or body]
> -----Original Message-----
> From: Kevin Carothers [mailto:kevindotcar@gmail.com]
> Sent: Monday, February 28, 2005 6:59 PM
> To: Neil Burnett
> Cc: perl-win32-users@activestate.com
> Subject: Re: Win32:OLE - Threadsafe?
>
> On Mon, 28 Feb 2005 13:12:40 +0100, Neil Burnett <neil@efc.be> wrote:
> > Has anything happened to solve this clean up issue with Win::OLE and
> threads?
> >
> > Free to wrong pool ... during global destruction
> >
> > I am avoiding the error at the moment by taking jan and paul's advice
> (thanks) collectively:
> >
> > - require not use Win32::OLE and do it inside the thread sub
> >
> > I have also had to comment out using Win32:OLE:Constants and revert to
> the actual numbers I need (E.g 65001 instead of Win32::OLE::CP_UTF8() ). I
> couldn't get them to work with use or require either inside or outside the
> thread sub.
> >
>
> Hello Neil,
> I have been burned by this problem before.
> It's not really a solution, but what I did to work around the issue is to
> use semaphores. Example;
>
> use DBI;
> use Win32::OLE;
> use Win32::OLE::Variant;
> use Win32::Semaphore;
> use Win32;
>
> [---]
> $strInsSQL = "INSERT INTO tbl (OfficeStreet1) ";
> $strInsSQL .= "VALUES ('".$INFO{'newost1'}."' ";
>
> my($Sem);
>
> Win32::Semaphore::Create($Sem,1,1,"SemBranch")||die &Error;
> if($Sem) {
> $Sem->wait();
> $sth = $dbh->prepare($strInsSQL);
> $sth->execute || Write_HTML_ERROR_sem("<b>ERROR Writing
> tblBranches Record<b>", $Sem, $lastBranch);
> $Sem->Release(1,$lastBranch);
> }
>
> ...something not shown is "Write_HTML_ERROR_sem()"
> you shouldn't just "die" if you get an error, because you should at
> least try to "release" your named semaphore... otherwise it will jam
> up everyone else who uses the semaphore. Google "about semaphores" if
> you need to get a background.
>
> KC
Thanks for the advice. At the moment, my single multi-threaded script is working fine \
with the arrangement I mentioned above, so I won't venture into semaphore territory \
unless I need it on the next script. Mind you, reducing my url validation code (it \
updates a database with the current responses) from 10 hours elapsed execution time \
to the same number of minutes using threads is very encouraging. I may use threads \
again much sooner than I thought! Regards - Neil
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic