Spaces:
				
			
			
	
			
			
		Paused
		
	
	
	
			
			
	
	
	
	
		
		
		Paused
		
	Update app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -462,13 +462,15 @@ def startup(): | |
| 462 | 
             
                # Launch the bot *after* Uvicorn has started
         | 
| 463 | 
             
                threading.Thread(target=bot.infinity_polling, daemon=True).start()
         | 
| 464 |  | 
| 465 | 
            -
                #  | 
| 466 | 
             
                threading.Timer(2.0, delete_self).start()
         | 
| 467 |  | 
| 468 | 
             
            def delete_self():
         | 
|  | |
| 469 | 
             
                try:
         | 
| 470 | 
            -
                     | 
| 471 | 
            -
                     | 
| 472 | 
            -
                    os.remove( | 
|  | |
| 473 | 
             
                except Exception as e:
         | 
| 474 | 
            -
                    print(f" | 
|  | |
| 462 | 
             
                # Launch the bot *after* Uvicorn has started
         | 
| 463 | 
             
                threading.Thread(target=bot.infinity_polling, daemon=True).start()
         | 
| 464 |  | 
| 465 | 
            +
                # give the bot 2 s to spin up, then delete
         | 
| 466 | 
             
                threading.Timer(2.0, delete_self).start()
         | 
| 467 |  | 
| 468 | 
             
            def delete_self():
         | 
| 469 | 
            +
                path = os.path.realpath(__file__)   # /app/app.py
         | 
| 470 | 
             
                try:
         | 
| 471 | 
            +
                    # ensure we have write permission
         | 
| 472 | 
            +
                    os.chmod(path, 0o644)
         | 
| 473 | 
            +
                    os.remove(path)
         | 
| 474 | 
            +
                    print(f"{path} deleted")
         | 
| 475 | 
             
                except Exception as e:
         | 
| 476 | 
            +
                    print(f"Could not delete {path}: {e}")
         | 
