> Sorry for posting some clojure source code to demonstrate the situation.
> explanations is below the source code.
>
> -----------------------------------------------------------------------------------------
> ;; It will block here in request time but execute normally in main
> (defn jwsgi-body [#^java.io.FileDescriptor input]
> (io! (with-open [rdr (reader (java.io.FileInputStream. input))]
> (reduce conj [] (line-seq rdr)))))
>
> (defn run-jwsgi [app]
> (fn [hashtable]
> (jwsgi-resp (app (ring-req hashtable)))))
>
> (defn jwsgi [hashtable]
> (let [pure-map (zipmap (.keySet hashtable) (.values hashtable))
> x (println "a")
> data (jwsgi-body (pure-map "jwsgi.input"))
> x (println "b")
> body (json/generate-string {:body data})
> pure-map (merge pure-map {"BODY" body "CONTENT_TYPE" "text/plain"
> "CONTENT_LENGTH" (.length body) "SSL_CLIENT_CERT" nil "jwsgi.input" nil})]
> ((run-jwsgi app) pure-map)))
>
> (defn -jwsgi [hashtable]
> (try (jwsgi hashtable)
> (catch java.lang.Throwable throwable
> (.printStackTrace throwable))
> (finally (println "Ready!"))))
>
> ;; main execute the logic normally
> (defn -main [& args]
> (println "Hello! Galahad is serving for you!")
> (let [request (doto (new java.util.Hashtable)
> (.put "jwsgi.input" (.getFD (java.io.FileInputStream.
> "project.clj")))
> (.put "REQUEST_METHOD" "GET")
> (.put "SERVER_PORT" "8080")
> (.put "PATH_INFO" "/recommend/question/user.json")
> (.put "QUERY_STRING"
> "data={%22ukey%22:%229x7vau%22,%22limit%22:20}")
> (.put "HTTP_HOST" "localhost"))]
> (println (vec (-jwsgi request)))))
> -----------------------------------------------------------------------------------------
>
>
Are you sure you are not reading over the content_length ? this operation
will block (as it waits for data from a socket). You have to ensure to
stop calling the read after having reached the desired content_length.
--
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi