From: Gerd S. <in...@ge...> - 2013-01-10 14:12:58
|
Am Donnerstag, den 10.01.2013, 13:19 +0100 schrieb Pierre-Alexandre Voye: > Hello, > > I'm facing more and more a problem with my application which is based > on NetHTTPd/NetCGI. > > > My software is based on CGI entry point (url and arguments values). > Each CGI opens a memcache + postgreSQL connexion, makes his task, > closes memcache + postgreSQL connexion and return the result (a string > of course, most of the time JSON data). > > > I use Memcache for several reasons, partly because of my inability to > understand how to use shared memory despite the tutorial. > > > > Some CGI are becoming to long to execute (more than 30s). > Usually, the result I need to return is calculated quickly (less than > 15s), but I need to make lot of treatments before returning it. > > Thus, I'm looking for a way to return the result my client need, and > continuing all tasks I need. So, I need to launch an asynchronous > task. > > > The ugly way I only see is to make my app calling itself by Http, give > to the CGI, all the information it need to continue the task. > > But it is so ugly, I can't make it this way. > > > Is there a way to lauch a task asynchronously ? > > Can I use a thread without risk ? Normally, yes, if you ensure that library functions do not "see" that there are several threads, i.e. any object is only used by one thread at a time. There are normally no mutexes controlling parallel access built-in (except where described). There are also no global variables making multi-threading impossible (and if so, there are mutexes around them). I must admit that I do not exactly understand your architectural problem. What I've got is that - You get a request via Nethttpd - You call your service routine via the CGI-style interface - that routine computes the result to return via CGI - but that routine also needs to do some side work that is not needed for the CGI return value, and could be run outside the strict HTTP request/response cycle The answer to the question how you can run such side work depends very much on how you deploy Nethttpd. Do you use the Netplex containers, or did you follow one of the simpler examples? Gerd > > Regards, > > > P-A > > > -- > --------------------- > https://twitter.com/#!/ontologiae/ > http://linuxfr.org/users/montaigne > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122712 > _______________________________________________ Ocamlnet-devel mailing list Oca...@li... https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel -- ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany ge...@ge... Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de *** Searching for new projects! Need consulting for system *** programming in Ocaml? Gerd Stolpmann can help you. ------------------------------------------------------------ |