'Telethon newMessage-Event does not get called in Apache-Storm python spout
I want to extract the telethon-Event in Strom, but the event doesnt get triggered. It works fine in standalone (without storm), but in a spout there is no activity on an new message. Why?
import storm
from telethon import TelegramClient, events, sync
from telethon.tl.functions.users import GetFullUserRequest
from telethon.tl.functions.channels import GetFullChannelRequest
from telethon.sessions import StringSession
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
from datetime import datetime
import time
class TelethonSpout(storm.Spout):
def initialize(self, conf, context):
self._conf = conf
self._context = context
storm.logInfo("Spout instance starting...")
def nextTuple(self):
api_id = 123456789
api_hash = '...'
session="...."
client = TelegramClient(StringSession(session), api_id, api_hash)
@client.on(events.NewMessage())
async def my_event_handler(event):
storm.logInfo("eve", event) # -> not called in storm
storm.emit(["extracted event data "])
client.start()
client.run_until_disconnected()
TelethonSpout().run()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
