#Goroutines and channels

31 messages · Page 1 of 1 (latest)

royal pendant
#

Hi guys, have a function that checks proxy from a list. Response sends in a channel and then in main function reads from it, but nothing happens, idk what to do((((
Also have this panic( Pls help me

stoic token
# royal pendant Hi guys, have a function that checks proxy from a list. Response sends in a chan...

You are not showing everything, first please consider providing the full console output
if there's panic: prefix you should also include it, if there's stack traces, you should also include it
the screenshot of code is not really helpful since the error is vague and you did not say much about it

you are also doing parallelism incorrectly, consider removing the last for loop out, and changing it to for range respchan instead of dats

royal pendant
fallen spindle
#

in main function, you only call one time SendReqBuy, but after called this function, your code in for range , but for range need recieve number of dats lens , but your code need recieve number of dats , and you only can recieve one mesage

stoic token
#

you did not provide the code so i cant say much other then whatever thing you use did not expect timeout to be exceeded

#

if you are using unreliable proxies they may be dead thus resulting in the timeout

stoic token
#

your code should be made to handle erratic and uncooperative network/proxy

#

consider not panicing on err!=nil

#

there you go

#

your code is told to panic if there's an error

#

so it does precisely what you told it to do

#

you should implement a state to retry failures, and if it fails enough times, give up on it by using another proxy, or exit the whole app by panicking if there's no usable proxy

royal pendant
#

problem in channels i suppose

stoic token
#

there is nothing to do with channel

#

this is the problem

#

you are not handling the error

#

you are panicking at sight of any error

royal pendant
#

and nothing happens

stoic token
#

i dont know about your code so i cant say much

#

you need to handle when errors are returned too

#

making it return an error wont solve problems

stoic token
#

you should try using the debugger to see what's happening then

stoic token
#

right now you are trying to

for {
  go startJob(resultCh)
  for result:= range resultCh {
    doThing(result)
  }
}
#

which means only the first job ever get started

#

what you want is to

for {
  go startJob(resultCh)
}
for result:= range resultCh {
    doThing(result)
}