List of methods affected by 'Special method lookup'

2019-01-28 Thread Roberto Martínez
Hi,

the documentation about Special method lookup

claims:
"For custom classes, implicit invocations of special methods are only
guaranteed to work correctly if defined on an object’s type, not in the
object’s instance dictionary. "

Does this statement holds for every special method mentioned in section 3.3
Special method names
?

Best regards,
Roberto
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30549] ProcessPoolExecutor hangs forever if the object raises on __getstate__

2017-06-02 Thread Roberto Martínez

New submission from Roberto Martínez:

Hi, I detected that a ProcessPoolExecutor hangs if the object fails to 
picklelize.

I attached the simplest code to reproduce the behavior. Note that the 
interpreter should exit after the exception but it doesn't and hangs forever.

I tested with python 3.4, 3.5 and 3.6 with the same results.

--
files: test_noshutdown.py
messages: 294999
nosy: Roberto Martínez
priority: normal
severity: normal
status: open
title: ProcessPoolExecutor hangs forever if the object raises on __getstate__
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file46919/test_noshutdown.py

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30549>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23582] multiprocessing.Queue.get is not getting all the items in the queue

2015-03-04 Thread Roberto Martínez

Roberto Martínez added the comment:

I think you misunderstood my explanation. My english is not very good, sorry.

I think that my previously attached file (mpqueuegetwrong.py) shows it better 
than my words. In this file you can see that I am not calling qsize nor 
get_nowait, only put and get. And the behavior I am reporting is only related 
to those methods (and I think it is not documented).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23582
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23582] multiprocessing.Queue.get is not getting all the items in the queue

2015-03-04 Thread Roberto Martínez

Roberto Martínez added the comment:

That's not my point.

To my understanding, when you put a item in the queue the item *must* be 
available to get in the next call. So I think put should block until the item 
is really in the queue so when you call get it return *always* and not some 
times (depending on the item size).

If this is not the expected behavior I think it should be warned in the put/get 
method.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23582
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23582] multiprocessing.Queue.get is not getting all the items in the queue

2015-03-04 Thread Roberto Martínez

New submission from Roberto Martínez:

We face yesterday a bug in a project, and after a few hours of investigation we 
found a bad/not documented behavior in multiprocessing.Queue.

If you put one or more items in a queue and if the items are large, there is a 
delay between the put is executed and the item is finally available in the 
queue. This is reasonable because the underlying thread and the pipe, but the 
problem is not this.

The problem is that Queue.qsize() is reporting the number of items put, 
Queue.empty() is returning True, and Queue.get() is raising Empty.

So, the only safe method to get all the items is as follows:

while q.qsize(): 
try: 
item = q.get_nowait()   
except Empty:
pass

Which is not very nice.

I attach a sample file reproducing the behavior, a single process put 100 
elements in a Queue and after that it tries to get all of them, I tested in 
python 2.7.9 and 3.4 with the same result (seems python3 is a little bit faster 
and you need to enlarge the items). Also if you wait between get's, the process 
is able to retrieve all the items.

--
files: mpqueuegetwrong.py
messages: 237178
nosy: Roberto Martínez
priority: normal
severity: normal
status: open
title: multiprocessing.Queue.get is not getting all the items in the queue
type: behavior
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file38327/mpqueuegetwrong.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23582
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: [Python-Dev] Dinamically set __call__ method

2014-11-04 Thread Roberto Martínez
Yikes, I didn't realize the difference in inheritance.

The thing with this is tricky. I need the change in the instance, not in
the class, because I have multiple instances and all of them must have
different implementations of __call__.

The workaround of calling a different method inside __call__ is not valid
for my case because I want to change the *signature* of the function also
-for introspection reasons.

Thank you all.

Best regards,
Roberto

(Ethan, sorry for posting to python-dev, I thought that it was an
implementation detail of CPython 3.X)

On Tue, Nov 4, 2014 at 7:23 PM, Ethan Furman et...@stoneleaf.us wrote:

 This list is for the development _of_ Python, not development _with_
 Python.

 Try asking on Python List.

 (forwarding...)


 On 11/04/2014 08:52 AM, Roberto Martínez wrote:


 I am trying to replace dinamically the __call__ method of an object using
 setattr.
 Example:

 $ cat testcall.py
 class A:
  def __init__(self):
  setattr(self, '__call__', self.newcall)

  def __call__(self):
  print(OLD)

  def newcall(self):
  print(NEW)

 a=A()
 a()

 I expect to get NEW instead of OLD, but in Python 3.4 I get OLD.

 $ python2.7 testcall.py
 NEW
 $ python3.4 testcall.py
 OLD

 I have a few questions:

 - Is this an expected behavior?
 - Is possible to replace __call__ dinamically in Python 3? How?


 In 2.7 that would be a classic class, about which I know little.

 In 3.x you have a new class, one which inherits from 'object'.  When you
 replace __call__ you need to replace it the class, not on the instance:

   setattr(__self__.__class__, self.newcall)

 --
 ~Ethan~

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Dinamically set __call__ method

2014-11-04 Thread Roberto Martínez
On Tue, Nov 4, 2014 at 8:06 PM, Skip Montanaro skip.montan...@gmail.com
wrote:


 On Tue, Nov 4, 2014 at 1:01 PM, Roberto Martínez 
 robertomartin...@gmail.com wrote:

 The workaround of calling a different method inside __call__ is not valid
 for my case because I want to change the *signature* of the function also
 -for introspection reasons.


 You could define __call__ like so:

 def __call__(self, *args, **kwds):
 self._my_call(*args, **kwds)


This was my first approach, but it is not very informative to the user and
I prefer to have arguments with descriptive names. We have to change
__doc__ too, so this is not an ideal solution for me.

I tried to implement __getattribute__, but is not called either. :(

then set self._my_call at runtime.

 Skip


-- 
https://mail.python.org/mailman/listinfo/python-list