Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' #3498

Closed
tonybaloney opened this issue Jun 21, 2017 · 17 comments
Closed

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int' #3498

tonybaloney opened this issue Jun 21, 2017 · 17 comments

Comments

@tonybaloney
Copy link
Contributor

I see this issue in the st2sensorcontainer log.

2017-06-20 23:27:00,324 140022676082032 ERROR threading [-] Exception in thread Thread-18:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib/python2.7/multiprocessing/pool.py", line 361, in _handle_tasks
    cache[job]._set(ind + 1, (False, ex))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

2017-06-20 23:27:00,326 140022676082032 ERROR threading [-]
@LindsayHill
Copy link
Contributor

Which sensors are you running there?

@LindsayHill
Copy link
Contributor

Need some more info on what sensors/config you're running there. Can re-open if we have that info

@guptasakshi01
Copy link

guptasakshi01 commented May 16, 2018

Hi,

I am also getting same error:-

2018-05-15 21:21:58,247 ERROR [-] Exception in thread Thread-18:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 361, in _handle_tasks
cache[job]._set(ind + 1, (False, ex))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

2018-05-15 21:21:58,248 ERROR [-]

-: While trying to execute for following block of code in sensor:-
Following block of code iterates over all the unread emails in inbox and mark then as read
Code in Sensor

for item in account.inbox.filter(is_read=False):
item.is_read = True
item.save()
self._logger.debug(item.author.email_address)

This code is working as expected in Python But Throwing error mentioned above while executing it via sensor

@tonybaloney Did you find any resolution ?
@LindsayHill Please help

@LindsayHill
Copy link
Contributor

Which sensor?

@guptasakshi01
Copy link

Sensor to monitor mailbox.That uses exhangelib module of python.

@LindsayHill
Copy link
Contributor

Is this your own custom code? Please post a link to the code

@guptasakshi01
Copy link

guptasakshi01 commented May 17, 2018

Please find link for code.

https://github.com/guptasakshi01/St2/blob/master/monitor_mailbox.py

I am facing issue on line number 87. Where We are iterating over all the unread mails containing subject as Test
Whereas same block in working fine with python.
Please help

@Kami
Copy link
Member

Kami commented May 17, 2018

@guptasakshi01 It looks like some issue related to threading interaction with eventlet monkey patch.

I would try replacing:

eventlet.monkey_patch(
    os=True,
    select=True,
    socket=True,
    thread=True,
    time=True)

with

eventlet.monkey_patch(
    os=True,
    select=True,
    socket=True,
    thread=False,
    time=True)

In your sensor code.

And if that doesn't work, removing eventlet.monkey_patch line all together.

@LindsayHill
Copy link
Contributor

You should probably also look at the existing MS Exchange pack https://github.com/StackStorm-Exchange/stackstorm-msexchange/

I believe that has issues in some scenarios, but it would be better to start with that, and fix that, rather than write your own code. Better to leverage other's work, and share your improvements.

@guptasakshi01
Copy link

@LindsayHill We are not able to use senders email address in this given sensor, Is there any other way I can use the email address of sender as payload while dispatching trigger?

@Kami It didn't work Is there any other solution??

@LindsayHill
Copy link
Contributor

It looks like it would be trivial to modify the existing sensor to also return the sender ID. e.g. probably change this line https://github.com/StackStorm-Exchange/stackstorm-msexchange/blob/master/sensors/item_sensor.py#L52 and the item_sensor.yaml.

Have you tried doing that, rather than writing a whole new sensor?

@guptasakshi01
Copy link

guptasakshi01 commented May 22, 2018

Hi @LindsayHill ,
I am receiving same error while using (existing module) item_sensor.py.

2018-05-22 03:29:09,381 ERROR [-] Exception in thread Thread-18:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib/python2.7/multiprocessing/pool.py", line 361, in _handle_tasks
cache[job]._set(ind + 1, (False, ex))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

@Kami
Copy link
Member

Kami commented May 22, 2018

@guptasakshi01 Which StackStorm version are you using?

If you didn't upgrade yet, try upgrading to v2.7.2.

@guptasakshi01
Copy link

guptasakshi01 commented May 22, 2018

@Kami stackstorm version :- st2 2.7.1

@guptasakshi01
Copy link

@Kami Thanks for your help
It worked as expected with 2.7.2

@Kami
Copy link
Member

Kami commented May 22, 2018

Great - glad to hear that.

I will close that issue as resolved in v2.7.2.

@Kami Kami added this to the 2.7.2 milestone May 22, 2018
@LindsayHill
Copy link
Contributor

@guptasakshi01 now that we've fixed your problem, can you please submit a PR to the MSExchange pack to add the missing functionality that you needed? This will probably help someone else who needs it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants