Re: [go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-27 Thread Nico Braun
On Thursday 24 October 2024 at 18:42:35 UTC+2 robert engels wrote: > In my experience, the OPΓÇÖs issue points to a code structure problem > and not having a deterministic lifecycle for the channels. I agree with this strongly. I think therere should be an owner of the channel in some way, usually

Re: [go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-25 Thread Robert Engels
That is exactly how the code I referenced you to works. Your structures appear inverted. When the client socket disconnects it should be removed from the structure the writer is using. If you don’t do this properly you have a race condition anyway. On Oct 25, 2024, at 7:57 AM, 'Aniket Pandey' via g

Re: [go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-25 Thread Jason E. Aten
Hi Aniket - you probably have a race and per Robert, should restructure not to close the channel ever. We can help you more directly if you would kindly post a playground code example that illustrates the essentials of what you are doing. See https://go.dev/play/ then press Share and reply

Re: [go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-25 Thread 'Aniket Pandey' via golang-nuts
Thanks for the ideas guys !! but in my case i have constant running process irrespective number of writes as my writer channel won't stop sending data directly as it has only check if the client Active and that is made false once the Socket Reader function exits and after that i close the chan

Re: [go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-25 Thread Jason E. Aten
Robert makes an insightful point. You probably don't want to be closing channels that have actual data conveyed / sent through them in the first place. Closing a channel is most often used as a means of broadcasting a state change, rather than signaling EOF (end of file). Doing for-range loop

Re: [go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-24 Thread robert engels
In my experience, the OP’s issue points to a code structure problem and not having a deterministic lifecycle for the channels. You rarely need specific/additional state to track this. You can look at github.com/robaho/go-trader which uses multiple channels

[go-nuts] Check Channel is active or not while Writing as writer Go routine

2024-10-24 Thread 'Aniket Pandey' via golang-nuts
Has anyone have implemented the logic in order to check if the channel is active if the channel is active then only will write the data .if yes how to do so? As i am getting the Following error: *panic: **send on closed channel* As a writer go routine i want to only write data to active channe