asynchat - operation could not complete w/ blocking

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andreas R.

    #1

    asynchat - operation could not complete w/ blocking

    Hi again,

    I'm using Python's asynchat module for networking.
    When calling the sendall() method of asynchat,
    I sometimes get the error message "the operation
    could not complete without blocking".

    So how do I enable blocking with synchat, or otherwise fix this error?

    Thanks for the help I've received with asynchat so far in this news group.

    - Andreas
  • Fredrik Lundh

    #2
    Re: asynchat - operation could not complete w/ blocking

    "Andreas R." wrote:
    [color=blue]
    > I'm using Python's asynchat module for networking.
    > When calling the sendall() method of asynchat,
    > I sometimes get the error message "the operation
    > could not complete without blocking".[/color]

    what sendall method ? to get proper output buffering with asynchat, use
    "push" (or "push_with_prod ucer").

    </F>



    Comment

    • Andreas R.

      #3
      Re: asynchat - operation could not complete w/ blocking

      Fredrik Lundh wrote:[color=blue]
      > "Andreas R." wrote:
      >[color=green]
      >> I'm using Python's asynchat module for networking.
      >> When calling the sendall() method of asynchat,
      >> I sometimes get the error message "the operation
      >> could not complete without blocking".[/color]
      >
      > what sendall method ? to get proper output buffering with asynchat, use[/color]

      Search for sendall here:


      That's what I was told to use here:


      That's not correct? You can try the version using sendall here:


      -Andreas

      Comment

      • Andreas R.

        #4
        Re: asynchat - operation could not complete w/ blocking

        Fredrik Lundh wrote:[color=blue]
        > "Andreas R." wrote:
        >[color=green]
        >> I'm using Python's asynchat module for networking.
        >> When calling the sendall() method of asynchat,
        >> I sometimes get the error message "the operation
        >> could not complete without blocking".[/color]
        >
        > what sendall method ? to get proper output buffering with asynchat, use
        > "push" (or "push_with_prod ucer").[/color]

        The problem I was having with push, is that is does not always send
        complete packages.

        The solution to this was to use sendall() instead, but sendall() gives
        blocking error messages.

        - Andreas

        Comment

        • Erik Max Francis

          #5
          Re: asynchat - operation could not complete w/ blocking

          Andreas R. wrote:
          [color=blue]
          > The problem I was having with push, is that is does not always send
          > complete packages.
          >
          > The solution to this was to use sendall() instead, but sendall() gives
          > blocking error messages.[/color]

          The purpose of asynchat's push methods is to queue outgoing data and
          send it when possible. When you're complaining that it does not always
          send complete packages, that strongly implies to me that you're
          misunderstandin g how socket transmissions work.

          With TCP you're guaranteed that data will show up in the same order you
          sent it. You're not at all guaranteed that it will show up in the same
          chunks, or that you will get it all at the same time.

          The only time you'd want to do use something like "sendall" is when you
          really _do_ want to block until you make sure all the data is sent. So
          if you're wondering why it blocks, that suggests a deep misunderstandin g
          in how TCP works.

          If you want to use asynchat to transmit data, all you need to do is set
          things up so that push handles them. Once that's the case, the data
          will be transmitted when the socket is writable such that it doesn't
          block. In other words, all you want to do is call
          push/push_with_produ cer and leave it at that.

          --
          Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
          San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
          Eppur, si muove! [But still it moves!]
          -- Galileo Galilei

          Comment

          • Andreas R.

            #6
            Re: asynchat - operation could not complete w/ blocking

            Dennis Lee Bieber wrote:[color=blue]
            > On Wed, 08 Mar 2006 08:57:53 +0100, "Andreas R."
            > <andreas@nospam .openrts.org> declaimed the following in
            > comp.lang.pytho n:
            >
            >[color=green]
            >> The problem I was having with push, is that is does not always send
            >> complete packages.
            >>
            >> The solution to this was to use sendall() instead, but sendall() gives
            >> blocking error messages.
            >>[/color]
            > Somehow, the above seems logical... "push" probably doesn't "send
            > complete packages" because doing so would require blocking; instead it
            > sends what won't block, presuming "you" (the programmer) will code
            > whatever is needed to handle partial sends and put the rest out on a
            > later "push".
            >
            > "sendall" may be sending everything, but it does so by blocking
            > until the other end acknowledges enough packets have been received to
            > ensure that no data is lost.[/color]

            Yes, this is how I understood sendall. But why does it sometimes report
            the error: (10035, 'The socket operation could not complete without
            blocking')


            - Andreas

            Comment

            • Fredrik Lundh

              #7
              Re: asynchat - operation could not complete w/ blocking

              (possible duplicate; reposted due to mail server problems)

              "Andreas R." `wrote:
              [color=blue][color=green]
              >> what sendall method ? to get proper output buffering with asynchat, use[/color]
              >
              > Search for sendall here:
              > http://svn.gna.org/viewcvs/openrts/t...67&view=markup
              >
              > That's what I was told to use here:
              > http://groups.google.no/group/comp.l...30540bd8ec9db5
              >
              > That's not correct?[/color]

              nope. asyncore uses it's own send implementation, and asynchat implements
              proper buffering on top of asyncore's send via the push methods.

              the reason that you could call sendall appears to be that asyncore gives you
              access to *all* socket object attributes via dynamic inheritance, and nobody
              thought of filtering out the sendall method (which is a rather recent addition
              to the socket layer). this should probably be fixed.

              </F>



              Comment

              • Fredrik Lundh

                #8
                Re: asynchat - operation could not complete w/ blocking

                "Andreas R." wrote:
                [color=blue][color=green][color=darkred]
                >>> I'm using Python's asynchat module for networking.
                >>> When calling the sendall() method of asynchat,
                >>> I sometimes get the error message "the operation
                >>> could not complete without blocking".[/color][/color][/color]
                [color=blue][color=green]
                >>
                >> what sendall method ? to get proper output buffering with asynchat, use[/color][/color]
                [color=blue][color=green]
                >> "push" (or "push_with_prod ucer").[/color]
                >
                > The problem I was having with push, is that is does not always send
                > complete packages.[/color]

                that sounds like a bug on the receiving side. the network layer is free
                to split things up however it likes, and it's up to your code to put things
                together again properly.
                [color=blue]
                > The solution to this was to use sendall() instead, but sendall() gives
                > blocking error messages.[/color]

                sendall is blocking per definition (and it doesn't send complete packages
                either; it just loops until it has managed to hand everything over to the net-
                work layer).

                </F>



                Comment

                • Fredrik Lundh

                  #9
                  Re: asynchat - operation could not complete w/ blocking

                  "Andreas R." wrote:

                  [color=blue][color=green]
                  >> "sendall" may be sending everything, but it does so by blocking
                  >> until the other end acknowledges enough packets have been received to
                  >> ensure that no data is lost.[/color]
                  >
                  > Yes, this is how I understood sendall. But why does it sometimes report
                  > the error: (10035, 'The socket operation could not complete without
                  > blocking')[/color]

                  in this context, that error message means "I cannot buffer more data right now,
                  please come back later".

                  "sendall" (which is designed for blocking sockets) treats that as an error, while
                  asyncore's send and push methods do the right thing (i.e. waits until the socket
                  layer signals that it's ready to handle more data).

                  </F>



                  Comment

                  Working...