Sujet : Event loop and http::geturl
De : jonkelly (at) *nospam* fastmail.fm (Jonathan Kelly)
Groupes : comp.lang.tclDate : 23. Jun 2025, 21:55:45
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103cf0h$1glgk$1@dont-email.me>
User-Agent : Mozilla Thunderbird
This is related to my other "too many nested evaluations".
I have taken a snapshot of my apache logs that caused the "..too many nested evaluations" and stripped down my program a bit so I could try and track down what was going on.
So, it looks like ::http::geturl is operating asynchronously, despite my program NOT using -command.
In the log I'm seeing:
----------------------
A before do_get_abuse 132.226.122.74 and ::last_ip is ##
do_get_abuse 132.226.122.74
get_abuse 132.226.122.74
get_abuse 132.226.122.74 before geturl
A before do_get_abuse 132.226.122.74 and ::last_ip is ##
----------------------
The "A before ..." line is coming from the proc checkForError that is attached to the fileevent
set ::accessLog [open "|cat access_test.log" r]
fconfigure $::accessLog -blocking 0 -buffering line
fileevent $::accessLog readable [list checkForError $::accessLog]
checkForError eventually calls do_get_abuse
proc do_get_abuse {ip} {
log "do_get_abuse $ip"
if { [catch {get_abuse $ip} result] } {
puts "get_abuse failed ... $result"
exit
}
}
and in get_abuse I have
log " get_abuse $ip before geturl"
set token [::http::geturl ${url}?${query} -method GET -headers $headers]
log " get_abuse $ip after geturl"
It never gets to the "log get_abuse $ip after geturl", which it should BEFORE the next fileevent readable event is processed.
This is at least contrary to the man page. From the man page:
The ::http::geturl command blocks until the operation completes, unless the -command option specifies a callback that is invoked when the HTTP transaction completes.
I'm going to start building a slow-ish webpage on one of our servers to investigate further with a minimal program.
Hopefully, someone on the guru team could check the http::geturl code?
Thanks
Jonathan.