(For the record, please forgive any logical errors in this spec, or errors in the understanding of how PDFKit and Rack middleware work. If that is the case, I puts the results to the console. If request_one asked for pdf, it should be quite surprised to receive html. If two requests come in simultaneously, one for pdf and one for html, then the content of the requests should come back in the specified format. The assumptions here should be easy to follow, but here's what it's theoretically testing. NB: This is awful code, but it's just here to prove a point. Require "net/http" def base_url " end def request_url ( id, type ) if type = :pdf base_url "/ # \r" end i = 1 end Sender, and may not reflect the official position of Continuity. Opinions and ideas expressed herein are solely those of the If you received thisĮmail in error, please notify the sender, delete the email and destroy allĪttachments. This email and all files transmitted with it are intended solely for use by Reply to this email directly, view it on GitHub You are receiving this because you are subscribed to this thread. In the base project, several months without code support. Have you got any concurrency issue after the fix? And why there is not fix Would you be willing to write some specs so our fix can be merged upstream? I can't speak for the pdfkit maintainers but as someone responsible for aįew large code bases I stand by their request for tests before merging. ![]() PDFKit team: are you aware of this pattern? What are your thoughts on threadsafety? Does this approach sound sane to you? If our fork fixes our problems, we're happy to tidy it up into a pull request, if the PDFKit maintainers like it. We're in the process of updating our fork of PDFKit to not set instance variables, by using the dup pattern, and will report back here as we watch our production servers, but I wanted to raise the question here sooner than later. PDFKit::Middleware sets and which are key to the process of rendering the PDFs. This allows the web server to use a separate (duped) object for each thread which will contain different data, based on it’s execution. By adding the _call method and duplicating the object we make sure that any instance variables we set in _call will be set on the duped instance, not the original. ![]() Since our middleware runs on, it has to be thread-safe, meaning, it should easily spawn multiple duplicates of it so different threads can use different objects of the same middleware. ![]() We started googling, and found several fairly recent articles - here is a good example - that suggest not setting instance variables in #call. This suggests to me that the middleware may not be threadsafe. One of the debug params was the value of and that showed us that we were seeing different paths than the one we were requesting. To debug, we hacked into PDFKit::Middleware#call to add debugging response headers. We started noticing some really strange problems with PDF requests that had been routed through PDFKit::Middleware.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |