python timeout exception example

Example: python timeout exception

--------------------------------------------------------------
Timeout function
--------------------------------------------------------------
import asyncio
from async_timeout import timeout

class Student:
  	def __init__(self):
      	self.queue = asyncio.Queue()
      	pass
  	
	async def function(self):
      	try:
    		async with timeout(300): # 5 minutes...
              	#source = await self.queue.get()
            	
                #do what u need to do
                pass
                
        except asyncio.TimeoutError as e:
        	print(e)
            
            
--------------------------------------------------------------
Requests
--------------------------------------------------------------
import requests as r

class Student:
	def __init__(self):
      	pass
      
  	def function(url:string):
		try:
    		data = r.get(url, timeout=10.0)
		except requests.Timeout as err:
    		logger.error({"message": err.message})
		except Exception as err:
          	print(err)
        return data # or what ever u need to return