[racket-users] make-http-connection and connection reuse

2021-05-02 Thread Alex Harsányi
The documentation for make-http-connection indicates that the same 
connection can be reused repeatedly, unfortunately, this does not seem to 
work.

https://docs.racket-lang.org/net/url.html?q=make-http-connection#%28def._%28%28lib._net%2Furl..rkt%29._make-http-connection%29%29

Here is an example program:

#lang racket
(require net/url net/url-connect net/head)

(define (tile->osm-url zoom x y)
  (string->url (format "https://tile.openstreetmap.org/~a/~a/~a.png"; zoom x 
y)))

(define user-agent "racket")

(define (run-test download-count)
  (parameterize ((current-https-protocol 'secure))
(let ((connection (make-http-connection)))
  (for ([try (in-range 1 download-count)])

(printf "download ~a..." url)(flush-output)
(define-values (port headers)
  (get-pure-port/headers
   (tile->osm-url 14 try 1)
   (list user-agent)
   #:connection connection))

(define content-type (extract-field "Content-Type" headers))
(define data (port->bytes port))
(unless (equal? content-type "image/png")
  (printf "expected a PNG image~%"))
(printf " done.~%")(flush-output)
;; discard the data and start a new loop
)
  (http-connection-close connection

(run-test 1000)

If you run the above program and monitor the racket process (I used 
procexp.exe on Windows, but you can use lsof on Linux), you'll notice that 
each request creates a separate socket connection, rather than reusing it, 
and these connections hang around for a long time before being closed.

Is this a bug in make-http-connection and/or get-pure-port/headers, or am I 
using it incorrectly in the example above?

This was noticed by someone on my map-widget package, and switching to 
`http-easy` solved the immediate problem (thanks Bogdan for that package!), 
but I thought I will ask here anyway, in case this is a bug.

Thanks,
Alex.


-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/825d24ac-ddb6-40ef-8101-dc85982addfdn%40googlegroups.com.


Re: [racket-users] Package install conflicts on the Racket package catalog

2021-05-02 Thread unlimitedscolobb
Hi Jay,

Thanks a lot for helping me read that file!

I didn't know Scribble outputs shared the same namespace.  I renamed the 
documentation file to typed-compose.scrbl as you suggest and I'm waiting 
for build reports from the package catalog.

In fact, I hesitated between manual.scrbl and typed-compose.scrbl 
initially, and couldn't find a reason to prefer one over the other. Now I 
have a reason :-)

-
Sergiu

On Saturday, May 1, 2021 at 3:23:47 PM UTC+2 jay.mc...@gmail.com wrote:

> Howdy Sergiu,
>
> The conflicts file you link to has all the conflicts for everything
> that `pkg-build` builds. The line relevant for you is:
>
> ```
> doc "manual":
> bystroTeX cbor print-debug ratchet riff simply-scheme typed-compose
> ```
>
> The solution is to rename your manual from `manual.scrbl` to
> `typed-compose.scrbl`. Scribble outputs are in a kind of "global"
> namespace.
>
> Jay
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
>
> --
> Jay McCarthy
> Associate Professor @ CS @ UMass Lowell
> http://jeapostrophe.github.io
> Vincit qui se vincit.
>
>
> On Sat, May 1, 2021 at 5:56 AM unlimitedscolobb
>  wrote:
> >
> > Hello,
> >
> > I checked my package 
> https://pkgd.racket-lang.org/pkgn/package/typed-compose recently and 
> noticed that it listed some "Conflicts" in the field "Most recent build 
> results". On the other hand, the separate field "Conflicts" slightly above 
> says "None".
> >
> > When I open the log shown in "Most recent build results" (attached) it 
> starts with the line "Install conflicts:", which as far as I get are not 
> the same thing as "Package Conflicts" explained here in the manual: 
> https://docs.racket-lang.org/pkg/Package_Concepts.html#(part._concept~3aconflicts)
>  
> .
> >
> > What are install conflicts? Should I fix them? What is the command that 
> generates that log?
> >
> > (typed-compose also used to have an undeclared dependency, which I have 
> just fixed by updating it's info.rkt.)
> >
> > -
> > Sergiu
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to racket-users...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/03bfa876-6418-41a2-a37a-5c39ad13121cn%40googlegroups.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/eb380f03-7a73-40e7-a3a6-0e8c3252525an%40googlegroups.com.