MCPcopy Create free account
hub / github.com/dbunt1tled/python-fast-api / EmailWorker

Class EmailWorker

src/cmd/email_worker.py:17–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class EmailWorker(AsyncCLICommandBase):
18 async def execute(self, loop: asyncio.AbstractEventLoop) -> int:
19 try:
20 from src.cmd.worker.email.send_email import SendEmailHandler
21 from src.core.rabbit_mq.worker import RMWorker
22
23 worker = RMWorker(
24 consumer=self.container.rmq_consumer(), queue="p_email", exchange="p_email_exchange", log=self.log
25 )
26
27 await worker.initialize(loop=loop, handlers=[SendEmailHandler(container=self.container)])
28
29 try:
30 self.log.info("🚀 Starting email worker...")
31 await worker.start()
32 except asyncio.CancelledError:
33 self.log.info("🚦 Email worker cancelled, shutting down gracefully...")
34 return 0
35 except Exception as e:
36 self.log.error(f"🛑 Failed to start RabbitMQ worker: {e}")
37 return 1
38 finally:
39 await worker.stop()
40 self.log.info("🛑 Email worker stopped")
41
42 return 0
43
44 except Exception as e:
45 self.log.error(f"Email worker execution failed: {e}")
46 return 1
47
48
49if __name__ == "__main__":

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected