Support Questions

Find answers, ask questions, and share your expertise

Python Executescript processor

New Contributor

I am working on a python script to post messages to a irc chat. From what I understand I need to use session.get() in order to retrieve flowfiles from a queue. 

I have tried several things but have not been able to retrieve any files from the queue to successfully post. 




import socket
from import StreamCallback, InputStreamCallback

class PyStreamCallback(InputStreamCallback):
    def __init__(self):
       self.ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
       self.server = "" = ""
       self.botnick = ""
       self.ircsock.connect((self.server, 6667))
       self.ircsock.send(bytes("USER "+ botnick +" "+ botnick +" "+ botnick + " " + botnick + "\n"))
       self.ircsock.send(bytes("NICK "+ botnick +"\n"))

    def joinchan(self, chan):
      self.ircsock.send(bytes("JOIN "+ chan +"\n"))
      ircmsg = ""
      while ircmsg.find("End of /NAMES list.") == -1:
        self.ircmsg = ircsock.recv(2048)
        self.ircmsg = ircmsg.strip('\n\r')

    def sendmsg(self, msg,
      self.ircsock.send(bytes("PRIVMSG "+ target +" :"+ msg +"\n"))

flowFile = session.get()
if (flowFile != None):
  flowFile =,PyStreamCallback())



Super Collaborator

It is not explicitly mentioned, but I assume you are using the ExecuteStreamCommand processor to call your python code from?


If so, this example looks promising:


Alternately you could let something like python or spark streaming simply listen to a kafka bus to which nifi sends the messages to be processed.

- Dennis Jaheruddin

If this answer helped, please mark it as 'solved' and/or if it is valuable for future readers please apply 'kudos'.