[Cuis-dev] Cuis web package
Mark Volkmann
r.mark.volkmann at gmail.com
Wed Jun 12 09:04:20 PDT 2024
What can I do to prevent the `WebServer` instance from being garbage
collected?
I thought this would work:
- make `server` be an instance variable of my `MyWebServer` class
- set that variable in the `initialize` method of that class to a new
instance of `WebServer`
- create an instance of `MyWebServer` in a Workspace like this:
server := MyWebServer new.
That did not work. It seems the instance of `WebServer` that is supposedly
held by the instance of `MyWebServer` still gets GCed.
On Wed, Jun 12, 2024 at 10:23 AM Juan Vuletich <juan at cuis.st> wrote:
> Hi Mark,
>
> In Worspaces, variables not declared between vertical vars are "Workspace
> Variables" and live until the Workspace is closed.
> In methods, variables declared as temporaries, between vertical vars, may
> be garbage collected anytime after the method exits, unless there is some
> other reference to the contents.
>
> So, yes. It is very possible that that's the difference.
>
> Cheers,
>
> On 6/12/2024 11:27 AM, Mark Volkmann via Cuis-dev wrote:
>
> Is it possible the issue is that when I run the code from a Workspace, the
> server does not get garbage collected, but when I run it from within the
> `initialize` method, it does get garbage collected?
>
> On Tue, Jun 11, 2024 at 8:42 PM Mark Volkmann <r.mark.volkmann at gmail.com>
> wrote:
>
>> I created a class named `MyWebServer` and added this `initialize` method.
>>
>> initialize
>> "demonstrates using the WebServer class"
>>
>> server := WebServer new listenOn: 1961.
>> server addService: '/' action: [ :req | req send200Response: 'Home
>> Page' ].
>> server addService: '/hello' action: [ :req | req send200Response:
>> 'Hello World!' ]
>>
>> Then I entered this in a Workspace and ran "Do it":
>>
>> MyWebServer new
>>
>> This started a process named "WebServer's listener process" that I see in
>> a Process Browser window.
>>
>> If I browse localhost:1961, the browser just hangs. But if I enter that
>> same code in a Workspace, both routes work fine.
>> What am I missing?
>>
>> On Tue, Jun 11, 2024 at 7:24 PM Mark Volkmann <r.mark.volkmann at gmail.com>
>> wrote:
>>
>>> Thank you so much! This is exactly what I was looking for.
>>>
>>> On Tue, Jun 11, 2024 at 1:05 AM Bernhard Pieber via Cuis-dev <
>>> cuis-dev at lists.cuis.st> wrote:
>>>
>>>> Feature require: 'WebClient'.
>>>>
>>>> See class WebServer
>>>>
>>>> Cheers,
>>>> Bernhard
>>>>
>>>>
>>>> > Am 10.06.2024 um 14:39 schrieb Mark Volkmann via Cuis-dev <
>>>> cuis-dev at lists.cuis.st>:
>>>> >
>>>> > Can someone recommend a package I should look at to learn about
>>>> implementing HTTP endpoints in Cuis?
>>>> >
>>>> > ---
>>>> > R. Mark Volkmann
>>>> > Object Computing, Inc.
>>>> > --
>>>> > Cuis-dev mailing list
>>>> > Cuis-dev at lists.cuis.st
>>>> > https://lists.cuis.st/mailman/listinfo/cuis-dev
>>>>
>>>>
>>>> --
>>>> Cuis-dev mailing list
>>>> Cuis-dev at lists.cuis.st
>>>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>>>
>>>
>>>
>>> --
>>> R. Mark Volkmann
>>> Object Computing, Inc.
>>>
>>
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
>
>
> --
> Juan Vuletichcuis.stgithub.com/jvuletichresearchgate.net/profile/Juan-Vuletichindependent.academia.edu/JuanVuletichpatents.justia.com/inventor/juan-manuel-vuletichlinkedin.com/in/juan-vuletich-75611b3twitter.com/JuanVuletich
>
>
--
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240612/445d523e/attachment.htm>
More information about the Cuis-dev
mailing list