SstHttpClient - behaviour in error case ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

SstHttpClient - behaviour in error case ...

Marten Feldtmann-2
There is an example on the class side of SstHttpClient class>>fetch:url.

This works as expected, but change the workBlock to:

<pre>
...

workBlock := [|client|
    (client := SstHttpClient forTransportScheme: 'httpl') startUp.
    response := [client dummy: url] ensure: [client shutDown].
    sem signal.
    ].

...
</pre>

and you might notice, that #dummy: is an unknown message and should result in an exception.

When you now run the example, the system is blocked .... WHY ???


--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: SstHttpClient - behaviour in error case ...

Marten Feldtmann-2
The reason for the blocking is the usage of Semaphore. Perhaps a better implementation would be:

fetch: url
    "
        SstHttpClient fetch: 'http://time.gov/timezone.cgi?UTC/s/0'
    "
|workBlock response sem|

workBlock := [

        response :=
        [       
            |client|
           
            (client := SstHttpClient forTransportScheme: 'httpl') startUp.
            [     response := client get: url ]
                            ensure: [
                                    client shutDown.
                                    sem signal
                            ]
        ]
        when: ExError
        do: [ :sig | sig exitWith: nil ].
   
    ].

sem := AbtSemaphore new.
Processor activeProcess == UIProcess currentUI
    ifTrue: [
        workBlock
            forkAt: Processor userSchedulingPriority
            named: ('%1 [%2]' bindWith: self name with: Time now printString).
        sem wait.
]
    ifFalse: [workBlock value].

^response

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.