in reply to Re^2: How do I make a PSGI program do costly initialisation only once per process, not per thread?
in thread How do I make a PSGI program do costly initialisation only once per process, not per thread?

To comment out line #38 (loader => 'Delayed') in thrall.bat?

Setting environment variable PERL_THRALL_DEBUG=1, and adding something like say "...in main, thread is ", threads-> tid; into "main" of your app might help to debug.

Will this change to .bat break anything? I don't know, but...
  • Comment on Re^3: How do I make a PSGI program do costly initialisation only once per process, not per thread?
  • Select or Download Code

Replies are listed 'Best First'.
Re^4: How do I make a PSGI program do costly initialisation only once per process, not per thread?
by daxim (Curate) on Jun 07, 2017 at 11:02 UTC
    comment out line #38 (loader => 'Delayed') in thrall.bat
    You hit the nail on the head, bravo! So to make this crystal clear, the loader type is responsible for the difference in initialisation, not the server type itself, and with thrall, the delayed loading is on purpose.
    Will this change to .bat break anything?
    Yes, very much. It appears there is a lot of thread-unsafe code in my application. Let me show y'all a bizarre example:
    use JSON qw(encode_json); my $app = sub { return [200, [], [encode_json [] ]] };
    With plackup, the response is []. With thrall but no Delayed loader, the response is Internal Server Error, the exception hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at ….