Skip to content

How to close all cached connections #1137

@DrChainsaw

Description

@DrChainsaw

Please specify the following versions when submitting a bug report:

  • Julia 1.10.0-rc2
  • HTTP.jl 1.10.1
  • MbedTLS.jl 1.1.9

Is there a way to explicitly close all connections, including the ones which are globally cached in Connections.jl?

There is Connections.closeall() but it only seems to empty the pools with the references but does not actually close the connections before doing. Could this be a bug or is it the intended behaviour for some reason? It seems like it would cause the connections to leak.

Background is that I have a package which does need to query a webpage as part of the computations it does (for reasons beyond my control) and when I use PrecompileTools I get warnings like this:

[pid 26608] waiting for IO to finish:
│   Handle type        uv_handle_t->data
│   tcp[864]           000002281cc4f140->0000022821ce50a0
│   tcp[884]           000002281cc4e430->00000228206c4a60
│  This means that a package has started a background task or event source that has not finished running. For precompilation to complete successfully, the event source needs to be closed explicitly. See the developer documentation on fixing precompilation hangs for more help.

Fwiw, the precompilation does always complete in reasonable time (maybe the connections are closed when gc:ed?) and I get pretty nice speedups from it, so this is mostly about not getting the warning.

I have tried putting HTTP.Connections.closeall() last in the precompile script but it did not help. However, this helped: foreach(vs -> foreach(close, vs), values(HTTP.Connections.OPENSSL_POOL[].keyedvalues)), but I don't feel comfortable having that code in there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions