python – producer-consumer Pipeline problem implementation in asyncio

I wrote this code to make a non-blocking manager along with pipeline operations using asyncio, my main concern is to catch received items producer, and when the received operation is complete. I want to return all together and merged if keys matches, however, I have a doubt where should I have to join the data at the end producer or consumer in my case that the current workflow is the following

1 – scrape all databases ( multiples clients) (simulate)

2 – pushes to manager (proxy level server) where multiples clients send its data to the manger

3 – Merge multiple data sources into one list as per incoming data no DB operations yet example {"ID-2002-0201": {"id":"ID-2002-0201","updated_at":"2018-05-14T22:25:51Z","html_url":"xxxxxxxxxxxx"}} > maybe producer

4 – use a get_or_create ( check in the database if there isnt a record with that data , otherwise create it) > consumer

5 – create a bulk of data (maybe chunk the data into smaller chunks to be scalable when growing data source from 2 to 100+) > consumer

# #!/usr/bin/env python3
import asyncio
import logging
import random
from pipeline_async import Pipeline

class A:
    def __init__(self):

    def run(self):
        return {"ID-2002-0201":{"id":"ID-2002-0201","updated_at":"2018-05-14T22:25:51Z","html_url":"xxxxxxxxxxxx"}}

class B:
    def __init__(self):

    def run(self):
        return {"ID-2002-0202":{"id":"ID-2002-0202","updated_at":"2018-05-14T22:25:51Z","html_url":"xxxxxxxxxxxx"}}

class Manager:

    async def producer(self, pipeline, data_sources):
        """Pretend we're getting a number from the network."""
        for data_stream in data_sources:
            await pipeline.set_message(, "Producer")
  "Producer got message: %s", data_stream)

    async def consumer(self, pipeline):
        """ Pretend we're saving a number in the database. """
        while True:
            # wait for an item from the Producer
            message = await pipeline.get_message("Consumer")
            # process the msg
                "Consumer storing message: %s", message
            # simulate i/o operation using sleep
            await asyncio.sleep(random.random())

    async def start(self):
        pipeline = Pipeline()
        data_sources = (A(),B())
        # schedule the consumer
        consume = asyncio.ensure_future(self.consumer(pipeline))
        # run the producer and wait for completion
        await self.producer(pipeline, data_sources)
        # wait until the consumer has processed all items
        await pipeline.join()
        # the consumer is still awaiting for an item, cancel it
        consume.cancel()"Successfully shutdown the service.")

if __name__ == '__main__':

class Pipeline(asyncio.Queue):
    def __init__(self):

    async def get_message(self, name):
        logging.debug("%s:about to get from queue", name)
        value = await self.get()
        logging.debug("%s:got %s from queue", name, value)
        return value

    async def set_message(self, value, name):
        logging.debug("%s:about to add %s to queue", name, value)
        await self.put(value)
        print(name, value)
        logging.debug("%s:added %s to queue", name, value)

I would appreciate some feedback on cases I missed

unity – Help me i don’t know where is the problem

it pops up when I start walking my figure.

IndexOutOfRangeException: Index was outside the bounds of the array.
UnityStandardAssets.Characters.FirstPerson.FirstPersonController.PlayFootStepAudio () (at Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs:173)
UnityStandardAssets.Characters.FirstPerson.FirstPersonController.ProgressStepCycle (System.Single speed) (at Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs:160)
UnityStandardAssets.Characters.FirstPerson.FirstPersonController.FixedUpdate () (at Assets/Standard Assets/Characters/FirstPersonCharacter/Scripts/FirstPersonController.cs:131

using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
using Random = UnityEngine.Random;

#pragma warning disable 618, 649
namespace UnityStandardAssets.Characters.FirstPerson
    (RequireComponent(typeof (CharacterController)))
    (RequireComponent(typeof (AudioSource)))
    public class FirstPersonController : MonoBehaviour
        (SerializeField) private bool m_IsWalking;
        (SerializeField) private float m_WalkSpeed;
        (SerializeField) private float m_RunSpeed;
        (SerializeField) (Range(0f, 1f)) private float m_RunstepLenghten;
        (SerializeField) private float m_JumpSpeed;
        (SerializeField) private float m_StickToGroundForce;
        (SerializeField) private float m_GravityMultiplier;
        (SerializeField) private MouseLook m_MouseLook;
        (SerializeField) private bool m_UseFovKick;
        (SerializeField) private FOVKick m_FovKick = new FOVKick();
        (SerializeField) private bool m_UseHeadBob;
        (SerializeField) private CurveControlledBob m_HeadBob = new CurveControlledBob();
        (SerializeField) private LerpControlledBob m_JumpBob = new LerpControlledBob();
        (SerializeField) private float m_StepInterval;
        (SerializeField) private AudioClip() m_FootstepSounds;    // an array of footstep sounds that will be randomly selected from.
        (SerializeField) private AudioClip m_JumpSound;           // the sound played when character leaves the ground.
        (SerializeField) private AudioClip m_LandSound;           // the sound played when character touches back on ground.

        private Camera m_Camera;
        private bool m_Jump;
        private float m_YRotation;
        private Vector2 m_Input;
        private Vector3 m_MoveDir =;
        private CharacterController m_CharacterController;
        private CollisionFlags m_CollisionFlags;
        private bool m_PreviouslyGrounded;
        private Vector3 m_OriginalCameraPosition;
        private float m_StepCycle;
        private float m_NextStep;
        private bool m_Jumping;
        private AudioSource m_AudioSource;

        // Use this for initialization
        private void Start()
            m_CharacterController = GetComponent<CharacterController>();
            m_Camera = Camera.main;
            m_OriginalCameraPosition = m_Camera.transform.localPosition;
            m_HeadBob.Setup(m_Camera, m_StepInterval);
            m_StepCycle = 0f;
            m_NextStep = m_StepCycle/2f;
            m_Jumping = false;
            m_AudioSource = GetComponent<AudioSource>();
            m_MouseLook.Init(transform , m_Camera.transform);

        // Update is called once per frame
        private void Update()
            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");

            if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
                m_MoveDir.y = 0f;
                m_Jumping = false;
            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
                m_MoveDir.y = 0f;

            m_PreviouslyGrounded = m_CharacterController.isGrounded;

        private void PlayLandingSound()
            m_AudioSource.clip = m_LandSound;
            m_NextStep = m_StepCycle + .5f;

        private void FixedUpdate()
            float speed;
            GetInput(out speed);
            // always move along the camera forward as it is the direction that it being aimed at
            Vector3 desiredMove = transform.forward*m_Input.y + transform.right*m_Input.x;

            // get a normal for the surface that is being touched to move along it
            RaycastHit hitInfo;
            Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out hitInfo,
                               m_CharacterController.height/2f, Physics.AllLayers, QueryTriggerInteraction.Ignore);
            desiredMove = Vector3.ProjectOnPlane(desiredMove, hitInfo.normal).normalized;

            m_MoveDir.x = desiredMove.x*speed;
            m_MoveDir.z = desiredMove.z*speed;

            if (m_CharacterController.isGrounded)
                m_MoveDir.y = -m_StickToGroundForce;

                if (m_Jump)
                    m_MoveDir.y = m_JumpSpeed;
                    m_Jump = false;
                    m_Jumping = true;
                m_MoveDir += Physics.gravity*m_GravityMultiplier*Time.fixedDeltaTime;
            m_CollisionFlags = m_CharacterController.Move(m_MoveDir*Time.fixedDeltaTime);



        private void PlayJumpSound()
            m_AudioSource.clip = m_JumpSound;

        private void ProgressStepCycle(float speed)
            if (m_CharacterController.velocity.sqrMagnitude > 0 && (m_Input.x != 0 || m_Input.y != 0))
                m_StepCycle += (m_CharacterController.velocity.magnitude + (speed*(m_IsWalking ? 1f : m_RunstepLenghten)))*

            if (!(m_StepCycle > m_NextStep))

            m_NextStep = m_StepCycle + m_StepInterval;


        private void PlayFootStepAudio()
            if (!m_CharacterController.isGrounded)
            // pick & play a random footstep sound from the array,
            // excluding sound at index 0
            int n = Random.Range(1, m_FootstepSounds.Length);
            m_AudioSource.clip = m_FootstepSounds(n);
            // move picked sound to index 0 so it's not picked next time
            m_FootstepSounds(n) = m_FootstepSounds(0);
            m_FootstepSounds(0) = m_AudioSource.clip;

        private void UpdateCameraPosition(float speed)
            Vector3 newCameraPosition;
            if (!m_UseHeadBob)
            if (m_CharacterController.velocity.magnitude > 0 && m_CharacterController.isGrounded)
                m_Camera.transform.localPosition =
                    m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
                                      (speed*(m_IsWalking ? 1f : m_RunstepLenghten)));
                newCameraPosition = m_Camera.transform.localPosition;
                newCameraPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset();
                newCameraPosition = m_Camera.transform.localPosition;
                newCameraPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
            m_Camera.transform.localPosition = newCameraPosition;

        private void GetInput(out float speed)
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            m_IsWalking = !Input.GetKey(KeyCode.LeftShift);
            // set the desired speed to be walking or running
            speed = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());

        private void RotateView()
            m_MouseLook.LookRotation (transform, m_Camera.transform);

        private void OnControllerColliderHit(ControllerColliderHit hit)
            Rigidbody body = hit.collider.attachedRigidbody;
            //dont move the rigidbody if the character is on top of it
            if (m_CollisionFlags == CollisionFlags.Below)

            if (body == null || body.isKinematic)
            body.AddForceAtPosition(m_CharacterController.velocity*0.1f, hit.point, ForceMode.Impulse);

Problem with P mode (Canon 400D) only in off status and indicator of switch on doesn’t work

My camera is Canon 400D(digital rebel XTi). It sat on a shelf for quite some time.
When I set a battery (newly charged), the camera doesn’t switch on, I get this screen and switching on/off doesn’t make anything.
Before this problem appeared I have replaced clock battery with a new one, but I’m not sure that it caused this problem.

enter image description here

jakarta ee – problem with recapcha ERROR for site owner: Invalid key type

Im sure that my api keys are right , my domain is checked.
I used as a domain to develope every state of recapcha.
Recapcha return 0.9 and i set threshold = 0.99 to test the recapcha .
but it shows me everytime this ERROR for site owner: Invalid key type.
It seems problem from recapcahjs.
I’ve no idea.

Problem based on Little Picard Theorem

If $f, g, h$ are entire functions, such that $sin f(z) +cos g(z)+e^{h(z)}=0$,
Show that $f,g, h $ are constant functions.

Description: I wanted an application of Little Picard theorem but I am not understanding where to use the theorem.

algorithms – Dry run AC-3 on a CSP problem

A, Mary (M), Otto (O) and Dicky (D) would like to rent an apartment house. The house has three floors: G/F, 1/F, 2/F. Every floor has only one apartment. A, M, O and D must be assigned to exactly one floor. Note that more than one person can live in the same apartment. Consider the following constraints.

  • A and M cannot live in the same apartment.
  • D must live on a higher floor than O.
  • D must live alone.
  • If A and O live together, they must be on 1/F.
  • If A and O live separately, one of them must live on the 2/F.

The question asks let all variables have full domains. Enforce arc-consistency

I have this problem which I am not able to dry run with AC-3. Can someone offer some insight into this problem.

I found two possible solutions: P,M,O,D = 2,0,0,1 or 1,0,1,2

python – Project Euler Problem #277

I am trying to solve Euler project problem 277 using python 3.8. First, I will show my program and than ask specific questions for enhancements.

The problem is a modified version of Collatz sequence. The general rule of the new one is:

  • $ a_{n+1} = , ,, frac {a_n} 3 quad$ if $ a_n $ is
    divisible by 3. We shall denote this as a large downward step, “D”.

  • $ a_{n+1} = frac {4 a_n+2} 3 , , $ if $ a_n $ divided by 3
    gives a remainder of $ 1 $ . We shall denote this as an upward
    step, “U”.

  • $ a_{n+1} = frac {2 a_n -1} 3 , , $ if $ a_n $ divided by 3
    gives a remainder of $ 2 $ . We shall denote this as a small
    downward step, “d”.

For instance if $ a_1=231$ , then the sequence $ {a_n}={231,77,51,17,11,7,10,14,9,3,1} $ corresponds to the steps “DdDddUUdDD”.

The problem asks What is the smallest $ a_1 > 10^{15}$ that begins with the sequence “UDDDUdddDDUDDddDdDddDDUDDdUUDd”?

def modifCollatz(x, seq, num):
   if num == 0:
       return seq

   if x % 3 == 0:
       num -= 1
       x = x / 3
       return modifCollatz(x, seq, num)

   elif x % 3 == 1:
       num -= 1
       x = (4 * x + 2) / 3
       return modifCollatz(x, seq, num)

       x = (2 * x - 1) / 3
       num -= 1
       return modifCollatz(x, seq, num)

wordList = ()
for i in "UDDDUdddDDUDDddDdDddDDUDDdUUDd":

n = 10 ** 15
while True:
   if modifCollatz(n, (), 30)(0:30) == wordList:
       n += 3
  1. That works. I have tested using the example given in problem 277.

  2. I am aware that it’s using brute force and don’t know what can be done to improve efficiency. I was just able to think of adding solely finding the first 30 elements of each number and incrementing by 3 n += 3, which are probably the easiest ones. What can be done additionally?

inequality – A first course in Complex Analysis inequalities problem

I’m trying the exercise 27 of the pg. 14 of the book A First Course in Complex Analysis with Applications, which says the following (there are 2 exercises with the common Prove the following, but only this is the one I’m asking about):

Prove the following: If $|z|=2$, then $|z+6+8i| leq 13$.

I thought that this could be proved just by solving the inequality and check if the value given is inside the solution of the equation. This is:

$$ |z+16+8i| leq |z| + |16 + 8i|$$
$$ |z| + |16 +8i| leq 13$$
$$ |z| leq 13 – |16 + 8i|$$
The modulus of the given $|16 + 8i|$ is $2 +8sqrt{5} approx 18,89$, so the previous inequality must be wrong since a modulus cannot be negative.

Product import problem. Cannot be used with directory

I have a problem with import product. When i try import using this option, also import not working when i use “Advanced Pricing” but when i try use for example “Customer Addresses” import working correctly.

enter image description here

My exception.log call me error like

(2021-05-14 06:39:32) main.CRITICAL: Path "/var/www/html/store/var/importexport//DhrGxu1C7TTHZiuhYqftgqXk3seWjyZr.csv" cannot be used with directory "/var/www/html/store/pub/media/" {"exception":"(object) (Magento\Framework\Exception\ValidatorException(code: 0): Path "/var/www/html/store/var/importexport//DhrGxu1C7TTHZiuhYqftgqXk3seWjyZr.csv" cannot be used with directory "/var/www/html/store/pub/media/" at /var/www/html/store/vendor/magento/framework/Filesystem/Directory/PathValidator.php:63)"} ()

I set up permission 777 to var and pub folder. I have created directory like:


Please Help

String manipulation problem – Mathematica Stack Exchange

I have many strings of the following kind:


These are trees downloaded from the public database “TreeBase”. I import them as strings and I want to get rid of what officially is the node names in the Newick format.

To be precise, I want to delete everything that stands between a “)” symbol and THE NEXT “:” symbol.

For my example, I want to get the following:


However, if I do

StringReplace(string, ")" ~~ __ ~~ ":" -> ")")

what I get is this:


I.e., Mathematica replaces everything between the first “)” symbol and the LAST “:” symbol. But that’s not what I want.

Can anyone help with this please? Thanks so much!