Thanks for the solution, it worked both - using pn.bind and partial functions. I decided to go with the second option. However, it became buggy when I added --num-threads=0
to my service. What possibly could have made it wrong?
The error is found here: Serialization Problem is more frequent with thread pooling
After some digging, I realized that it lands on the “run” method that you shared, however, inconsistently hitting different line of code every time. I can safely assume that the issue is not with code, but rather the code with thread pooling.