Re: Event loop and http::geturl

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Event loop and http::geturl
De : jonkelly (at) *nospam* fastmail.fm (Jonathan Kelly)
Groupes : comp.lang.tcl
Date : 23. Jun 2025, 22:51:25
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103ci8t$1hdm9$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Here's my simple test to confirm that ::http:geturl is running asynchronously - unless I completely misunderstand what "block" means. slow.htm pauses for 2 seconds and outputs the date and time.
-----------
#!/usr/bin/tclsh
package require http
package require tls
http::register https 443 [list ::tls::socket -autoservername true]
proc test1 {} {
   incr ::cnt
   set url     "https://congresstravel.com.au/events.cgi/xx/slow.htm"
   puts "  test1 $::cnt before geturl "
   set token   [::http::geturl ${url} -method GET]
   puts "    $::cnt data is [::http::data $token]"
   ::http::cleanup $token
}
proc check {chan} {
   if {[gets $chan line] >= 0} {
     test1
   }
}
proc queue {} {
   set ::input [open "|cat test.txt" r]
   fconfigure $::input -blocking 0 -buffering line
   fileevent $::input readable [list check $::input]
}
proc doClose {} {
   set ::close "close"
}
set fd [open "test.txt" "w"]
for {set x 1} {$x < 10} {incr x} {
   puts $fd $x
}
close $fd
queue
after 20000 doClose
vwait close
file delete "test.txt"
-----------
output
===========
   test1 1 before geturl
   test1 2 before geturl
   test1 3 before geturl
   test1 4 before geturl
   test1 5 before geturl
   test1 6 before geturl
   test1 7 before geturl
   test1 8 before geturl
   test1 9 before geturl
     9 data is 24/06/25 07:47:03
     9 data is 24/06/25 07:47:03
     9 data is 24/06/25 07:47:03
     9 data is 24/06/25 07:47:02
     9 data is 24/06/25 07:47:02
     9 data is 24/06/25 07:47:01
     9 data is 24/06/25 07:47:01
     9 data is 24/06/25 07:47:01
     9 data is 24/06/25 07:47:01
===========

Date Sujet#  Auteur
23 Jun 25 * Event loop and http::geturl17Jonathan Kelly
23 Jun 25 +- Re: Event loop and http::geturl1Jonathan Kelly
24 Jun 25 `* Re: Event loop and http::geturl15Rich
24 Jun 25  `* Re: Event loop and http::geturl14Jonathan Kelly
25 Jun 25   `* Re: Event loop and http::geturl13et99
25 Jun 25    `* Re: Event loop and http::geturl12et99
25 Jun 25     `* Re: Event loop and http::geturl11et99
25 Jun 25      `* Re: Event loop and http::geturl10Jonathan Kelly
25 Jun 25       `* Re: Event loop and http::geturl9Rich
26 Jun 25        `* Re: Event loop and http::geturl8et99
26 Jun 25         +* File processing (was Event loop and http::geturl)2Alan Grunwald
26 Jun 25         i`- Re: File processing (was Event loop and http::geturl)1Ralf Fassel
26 Jun 25         `* Re: Event loop and http::geturl5Rich
26 Jun 25          `* Re: Event loop and http::geturl4Jonathan Kelly
26 Jun 25           `* Re: Event loop and http::geturl3et99
27 Jun 25            `* Re: Event loop and http::geturl2Christian Gollwitzer
27 Jun 25             `- Re: Event loop and http::geturl1Ralf Fassel

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal