![]() |
|
Think about Loose Coupling | |
PerlMonks |
HTTP Request and Threadsby banhmi (Initiate) |
on Sep 12, 2018 at 17:45 UTC ( #1222242=perlquestion: print w/replies, xml ) | Need Help?? |
banhmi has asked for the wisdom of the Perl Monks concerning the following question: Hi all. I'm aware Perl and threading don't have the best relationship, but this crash has been bugging me for a while. I'm wondering if anyone has encountered similar issues, or know what is going on here.
Basically, I want to create two threads that do a similar GET HTTP request and print the response out (please ignore the clumsy code, I tried to repro the crash in a rush). The first thread would run fine. But the second thread would always cause a crash with one of these errors:
I'm pretty sure one time both of the threads work, so the issue might be intermittent. I haven't had much luck looking for any clues. If anyone could point me in the right direction, I'd appreciate it greatly! Edit: I've been spending some time looking more at this. What I noticed is for my machine, specifically the fail conditions are, the first request sent by the user agent has to be in a thread that's joined right after its created. On the second request, thread or non-thread, it will mostly crash (around 98% for me, there were 3-4 runs that worked randomly). That said, a quick workaround I'm implementing right now is sending a simple non-thread GET request just to "plant the seed". Then the subsequent requests in threads or non-threads would run without problems. I'm using This is perl 5, version 24, subversion 3 (v5.24.3) built for MSWin32-x86-multi-thread-64int Edit 2: Per @ikegami and @Corion's comments, I tried using an http uri instead of https and that seems to run fine. It might be the case that SSL libraries (which are not pure Perl) are only loaded if we use https.
Back to
Seekers of Perl Wisdom
|
|