Coder Social home page Coder Social logo

Comments (4)

lordmauve avatar lordmauve commented on July 18, 2024

This is a very detailed report, and an interesting issue. I will look into it.

from chopsticks.

lordmauve avatar lordmauve commented on July 18, 2024

It looks as though the change in Python 3 is that an unbuffered file object opened with fdopen no longer returns exactly size bytes - instead it focuses on only doing one system call.

We don't actually need an unbuffered file object in general - when we create 'inpipe' in bubble.py, it is buffered. However, the problem is that if we make the sys.stdin file object in PYTHON_ARGS buffered, it could read extra data into its buffers, which is thrown away in bubble.py once we dup all the file descriptors around and open inpipe.

Here's a slightly odd solution that I think might work - only buffer the exact amount we need:

PYTHON_ARGS = [                                                                 
    '-usS',                                                                     
    '-c',                                                                       
    'import sys, os; _bsz = %d ;' % len(bubble) +                               
    'sys.stdin = os.fdopen(0, \'rb\', _bsz); ' +                                
                                                                                
    '__bubble = sys.stdin.read(_bsz); ' +                                       
    'exec(compile(__bubble, \'bubble.py\', \'exec\'))'                          
]  

Could you try this and let me know if it works for you?

from chopsticks.

lordmauve avatar lordmauve commented on July 18, 2024

I'm not very happy with that actually. What we really need to do is keep hold of whatever is in the buffer - either modify or re-use the file object. I guess the simplest thing would be to do the stdin dup() in PYTHON_ARGS and don't re-open stdin in bubble.py.

from chopsticks.

amigrave avatar amigrave commented on July 18, 2024

Here's my attempt following your directives. Tested on python2.7 and python3.5

from chopsticks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.