Code getting hanged or Killed constantly

def mongo(contractAddress, block):
    Block_Address = pymongo.MongoClient(connection_Url).get_database('Holders').Block_Address
    if Block_Address.find_one({'contractAddress': contractAddress}) == None:
        Block_Address.insert_one({
                  'contractAddress': contractAddress,
                  'Block': block
                })

@ray.remote
def contract(_block):
    web3 = Web3(Web3.WebsocketProvider(infuraURL))
    for i in range(len(web3.eth.get_block(_block).transactions)):
    address = web3.eth.getTransactionReceipt(web3.eth.get_block(_block).transactions[i].hex()).contractAddress
    if address != None:
        mongo(address, _block)

if __name__=="__main__":
    ray.init(address='auto')
    print('''This cluster consists of
    {} nodes in total
    {} CPU resources in total
    '''.format(len(ray.nodes()), ray.cluster_resources()['CPU']))
    web3 = Web3(Web3.WebsocketProvider(infura_url))
    latestBlock = web3.eth.get_block('latest').number
    del web3
    del infura_url
    ray.get([contract.remote(block) for block in reversed(range(latestBlock))])

I am not able to figure out why code is getting killed and sometime system gets hanged.

Could anyone provide some help

Hi @Aditi_Bhalawat there is no way for us to know what’s happening here by just reading the code you provided.

Could you 1) format your code with indent; 2) check the logs either in the console and /tmp/ray/session_latest/logs and provide more information about your case?

I added indent in the code.
And what is happening with code is that it runs for few minute and after the it stops and gives output as

killed

or the machine gets hanged.
I am not able to understand why is it happening like this.

Thanks for helping improve the code. Could you also check /tmp/ray/session_latest/logs to see whether something is broken?

Btw, I think this might not be related to ray. Could you also check whether the program OOM? Usually, when OOM killer got triggered, it’ll show killed or machine hangs. dmesg might give you some insights.

Could you tell me where to check logs ? And also how to check whether the program is OOM