unity – “Update cannot be an iterator block” when trying to wait for jump to finish

When you want a method that can pause its execution and resume later in Unity, that’s called a Coroutine, and it needs to be set up in a specific way. The return type has to be IEnumerator, not void.

That’s why the compiler complains when you try to put a yield return statement inside a void Update – “void” is not a type that can be used as an iterator, which is what Unity’s coroutines are built on.

If you change the return type to IEnumerator, Unity will tell you that the Update method is forbidden from being used as a coroutine. But that’s OK, we can start our own named whatever we like.

Here’s a version of your script with working syntax:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour
{

    Animator m_Animator;
    bool m_Jump;

    public CharacterController2D controller;

    public float runSpeed = 40f;

    float horizontalMove = 0f;
    bool jump = false;

    void Start()
    {
        m_Animator = gameObject.GetComponent<Animator>();

        // Start our coroutine when the MonoBehaviour activates.
        StartCoroutine(JumpPoll());
    }

    IEnumerator JumpPoll()
    {
        while(true) {
            // If you don't want to lock horizontal input while jumping,
            // then move this line into FixedUpdate. It's OK to read axes there.
            horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

            if (Input.GetButtonDown("Jump"))
            {
                jump = true;
                m_Animator.SetBool("Jump", true);

                // Pause this loop for 3 seconds while the rest of the game proceeds.
                yield return new WaitForSeconds(3);

                m_Animator.SetBool("Jump", false);
            }
            // Let the game run one frame, and resume next frame just like Update() does.
            yield return null;
        }
    }

    void FixedUpdate()
    {
        controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
        jump = false;
    }
}

Bitcoin-cli sendtoaddress error Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee

I am following the documentation to perform transactions when I put the command:
bitcoin-cli -regtest sendtoaddress “xx address” 1.0
return:

Fee estimation failed. Fallbackfee is disabled. Wait a few blocks or enable -fallbackfee.

In my bitcoin.conf I enable this option in fallbackfee = true or enabled but nothing happed

this is my mempoolinfo:

{
  "loaded": true,
  "size": 0,
  "bytes": 0,
  "usage": 0,
  "maxmempool": 300000000,
  "mempoolminfee": 0.00001000,
  "minrelaytxfee": 0.00001000
}

I have read the other posts but I still don’t have the solution, help.

sharepoint online – Need a help to figure out if there is a way to prevent MS Flow “Custom Responses – Wait for all responses” from sending notification to MS Teams

We have the following “Custom Responses – Wait for all responses” action inside MS Flow:-

enter image description here

Where we are attaching a file to the response email >> now the email which will be sent will contain the attachment which is fine >> but the notification which will be shown inside the MS Teams will not contain the attachment…

so i have the following 2 questions:-

  1. how we can attach the attachment to the notification which will be sent to MS Team?

  2. if point-1 can not be achieved >> then can we prevent the above “Custom Responses – Wait for all responses” from sending notification to MS Teams and only send a normal notification by email?

Thanks

Magento 2.3.2 Product Export Message: “Message is added to queue, wait to get your file soon”

Try to fix Following way..

Open below file

vendor/magento/module-import-export/Controller/Adminhtml/Export/Export.php

and replace below function

public function execute()
{
    if ($this->getRequest()->getPost(ExportModel::FILTER_ELEMENT_GROUP)) {
        try {
            $params = $this->getRequest()->getParams();
            $model = $this->_objectManager->create(MagentoImportExportModelExport::class);
            $model->setData($this->getRequest()->getParams());
            $this->sessionManager->writeClose();

            return $this->fileFactory->create(
                $model->getFileName(),
                $model->export(),
                MagentoFrameworkAppFilesystemDirectoryList::VAR_DIR,
                $model->getContentType()
            );

            /** @var ExportInfoFactory $dataObject */
            $dataObject = $this->exportInfoFactory->create(
                $params('file_format'),
                $params('entity'),
                $params('export_filter')
            );

            $this->messagePublisher->publish('import_export.export', $dataObject);
            $this->messageManager->addSuccessMessage(
                __('Message is added to queue, wait to get your file soon')
            );
        } catch (Exception $e) {
            $this->_objectManager->get(PsrLogLoggerInterface::class)->critical($e);
            $this->messageManager->addError(__('Please correct the data sent value.'));
        }
    } else {
        $this->messageManager->addError(__('Please correct the data sent value.'));
    }
    /** @var MagentoBackendModelViewResultRedirect $resultRedirect */
    $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
    $resultRedirect->setPath('adminhtml/*/index');
    return $resultRedirect;
}

Please don’t forget to clear cache after change in files

drivers – start /wait doesn’t wait. How to workaround without using pause in script (Script is meant to be unattended)

I have a script that is run after windows is installed and performs a vast number of tasks, including installation of drivers and various programs. The intent is that the script is run unattended.

I am adding code to install printer drivers, in this case the Canon TS8300 series.

I think the problem is that that the installer runs in several parts. The first step is to extract the drivers and various utilities that come with the installer. I notice that once the extraction has completed the script continues.

If I understand the /wait parameter on the start command (and please correct me if I’m wrong), this is expected behavior. That certainly seems to be the consensus from the searches I’ve done.

The command is;

start /wait "TS8300 Installation" /d "%SRC%PostInstallCanon" "win-ts8300-1_02-ea34_2.exe"

I’ve also tried with start /b /wait (apparently /wait /b is also known to not work).

As the next step in the code is to stop and delete a service that is installed, that fails because it’s executing before the service has been installed as the script does not wait. So I’ve temporarily added a pause but that means I have to be there to press the any key.

I thought about simply using ping x.x.x.x -n yy >nul and it might work if I get the value of yy right (which will probably vary depending on the PC). It’s better than using pause, but I was hoping there might be something a bit more elegant and fool proof.

Thoughts?

debian – How to make systemd network-online.target wait for multiple networks?

We have an ESXi virtual machine running Debian 10 and are encountering a problem with postfix starting too early. This is causing issues with resolv.conf not being populated before the postfix chroot. I’ve ensured that both

  • /lib/systemd/system/postfix.service
  • /lib/systemd/system/postfix@.service

files have the line

After=network-online.target nss-lookup.target

However we have multiple nics installed in this VM, with the /etc/network/interfaces file containing

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug ens192
iface ens192 inet static
        address 10.1.0.29/21
        dns-nameservers 10.1.0.20 10.1.0.23 

# The secondary network interface
allow-hotplug ens224
iface ens224 inet static
        address 192.168.1.8/24
        gateway 192.168.1.240

When I run

grep -E "(Postfix Mail Transport Agent|e1000|Link is Up|link is not ready|link becomes ready|resolv.conf differ|target)" /var/log/syslog

I see that network-online.target only waits for one of the nics to be online.

Jan 12 18:46:54 assp0 kernel: (    1.738897) e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
Jan 12 18:46:54 assp0 kernel: (    1.738897) e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
Jan 12 18:46:54 assp0 kernel: (    1.739922) e1000e 0000:0b:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
Jan 12 18:46:54 assp0 kernel: (    1.795419) e1000e 0000:0b:00.0 0000:0b:00.0 (uninitialized): registered PHC clock
Jan 12 18:46:54 assp0 kernel: (    1.859484) e1000e 0000:0b:00.0 eth0: (PCI Express:2.5GT/s:Width x1)
Jan 12 18:46:54 assp0 kernel: (    1.859486) e1000e 0000:0b:00.0 eth0: Intel(R) PRO/1000 Network Connection
Jan 12 18:46:54 assp0 kernel: (    1.859558) e1000e 0000:0b:00.0 eth0: MAC: 3, PHY: 8, PBA No: 000000-000
Jan 12 18:46:54 assp0 kernel: (    1.860245) e1000e 0000:13:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode
Jan 12 18:46:54 assp0 kernel: (    1.915403) e1000e 0000:13:00.0 0000:13:00.0 (uninitialized): registered PHC clock
Jan 12 18:46:54 assp0 kernel: (    1.979239) e1000e 0000:13:00.0 eth1: (PCI Express:2.5GT/s:Width x1)
Jan 12 18:46:54 assp0 kernel: (    1.979240) e1000e 0000:13:00.0 eth1: Intel(R) PRO/1000 Network Connection
Jan 12 18:46:54 assp0 kernel: (    1.979290) e1000e 0000:13:00.0 eth1: MAC: 3, PHY: 8, PBA No: 000000-000
Jan 12 18:46:54 assp0 kernel: (    1.981312) e1000e 0000:0b:00.0 ens192: renamed from eth0
Jan 12 18:46:54 assp0 kernel: (    1.994070) e1000e 0000:13:00.0 ens224: renamed from eth1
Jan 12 18:46:54 assp0 kernel: (    4.577652) IPv6: ADDRCONF(NETDEV_UP): ens224: link is not ready
Jan 12 18:46:54 assp0 kernel: (    4.583595) e1000e: ens224 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
Jan 12 18:46:54 assp0 systemd(1): Reached target Swap.
Jan 12 18:46:54 assp0 systemd(1): Reached target System Initialization.
Jan 12 18:46:54 assp0 systemd(1): Reached target Sockets.
Jan 12 18:46:54 assp0 systemd(1): Reached target Basic System.
Jan 12 18:46:54 assp0 systemd(1): Reached target Timers.
Jan 12 18:46:54 assp0 systemd(1): Reached target Network.
Jan 12 18:46:54 assp0 systemd(1): Reached target Network is Online.
Jan 12 18:46:54 assp0 systemd(1): Starting Postfix Mail Transport Agent (instance -)...
Jan 12 18:46:54 assp0 systemd(1): Reached target Login Prompts.
Jan 12 18:46:54 assp0 kernel: (    4.671007) IPv6: ADDRCONF(NETDEV_UP): ens192: link is not ready
Jan 12 18:46:54 assp0 kernel: (    4.671206) IPv6: ADDRCONF(NETDEV_CHANGE): ens224: link becomes ready
Jan 12 18:46:54 assp0 kernel: (    4.675749) e1000e: ens192 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
Jan 12 18:46:54 assp0 kernel: (    4.676553) IPv6: ADDRCONF(NETDEV_CHANGE): ens192: link becomes ready
Jan 12 18:46:55 assp0 postfix/postfix-script(750): warning: /var/spool/postfix/etc/resolv.conf and /etc/resolv.conf differ

I thought there was something you could write in the network config to indicate that connection was required before the OS would consider the network to be up, but I can’t seem to find that info.

Before I cludge together something that works enough for us, I would like to know how to make network-online.target wait for either all nics, or preferably, the ones I specify.

c++ – Allow one thread to execute section while others wait and resume

I have a requirement that is summarized below.

void update()
{
  |   |   |   |
  |   |   |   |
  |   |   |   |
 |  |  |  |
  =============
      meat           <--- Only one thread must execute here, the rest should skip it.
  =============
  |   |   |   |  <--- Other threads wait here until the "first" thread is done w/ "meat"
  |   |   |   |
  |   |   |   |
  |/  |/  |/  |/
}

From an outsider perspective, “meat” should be executed just once (by the first thread that encounters it)

This post is similar but differs in that it also requires other threads to execute the meat code block one at a time.

// testExecutive.cpp
#include <atomic>
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <thread>

struct Target {
  int nhits = 0;
  inline void hit() { ++nhits; }
};

struct Executive {
  Executive() = delete;
  Executive(int _Id, Target &_Tgt) : m_Id(_Id), m_Ready(false), m_Tgt(_Tgt) {}
  void update() {
    { // only one thread can execute this
      std::scoped_lock<std::mutex> lk(m_Mtx);
      // std::cout << "++Acquired lk " << m_Id << " | tid: " <<
      // std::this_thread::get_id() << "++n";
      if (!m_Ready.load()) {
        // std::cout << "==Updating" << m_Id << " | tid: " <<
        // std::this_thread::get_id() << "==n";
        m_Ready.store(true);
        m_Tgt.hit();
        m_Cv.notify_all();
      }
      // std::cout << "++Releasing lk " << m_Id << " | tid: " <<
      // std::this_thread::get_id() << "++n";
    }

    // the rest should wait here
    std::mutex wait_mtx;
    std::unique_lock<std::mutex> lk(wait_mtx);
    m_Cv.wait(lk, (&)() -> bool { return m_Ready.load(); });
  }
  inline void reset() { m_Ready.store(false); }

private:
  int m_Id;
  Target &m_Tgt;
  std::condition_variable m_Cv;
  std::mutex m_Mtx;
  std::atomic_bool m_Ready;
};

int main(int argc, char *argv()) {
  int n(2);
  if (argc >= 2) {
    n = atoi(argv(1));
  }
  Target tgt;
  Executive e(1, tgt);
  auto updFn = (&e)() { e.update(); };

  // update same executive from 3 threads. Repeat n times.
  int i(n);
  while (i > 0) {
    e.reset();
    {
      std::thread t1(updFn), t2(updFn), t3(updFn);
      t1.join();
      t2.join();
      t3.join();
    }
    --i;
  }
  std::cout << (n == tgt.nhits ? "(OK)" : "(ERR)") << " Updates: " << n << " | "
            << "Hits: " << tgt.nhits << "n";
  return 0;
}

I setup a simple method to verify that exactly one out of three threads executes the desired code. The method hit() is called in Executive::Update. Compile and test like so.

jaswant@HAL9000:~$ g++ testExecutive.cpp -lpthread --std=c++17
jaswant@HAL9000:~$ ./a.out 2
(OK) Updates: 2 | Hits: 2
jaswant@HAL9000:~$ ./a.out 100
(OK) Updates: 100 | Hits: 100
jaswant@HAL9000:~$ ./a.out 2
(OK) Updates: 2 | Hits: 2
jaswant@HAL9000:~$ ./a.out 4
(OK) Updates: 4 | Hits: 4
jaswant@HAL9000:~$ ./a.out 8
(OK) Updates: 8 | Hits: 8
jaswant@HAL9000:~$ ./a.out 16
(OK) Updates: 16 | Hits: 16
jaswant@HAL9000:~$ ./a.out 256
(OK) Updates: 256 | Hits: 256
jaswant@HAL9000:~$ ./a.out 1024
(OK) Updates: 1024 | Hits: 1024
jaswant@HAL9000:~$ ./a.out 8192
(OK) Updates: 8192 | Hits: 8192
jaswant@HAL9000:~$ ./a.out 100000
(OK) Updates: 100000 | Hits: 100000

So, it works. Can anyone please point out bad usage of mutex/condition variables/locks and perhaps a way to do this w/o an atomic variable in the predicate?

commerce – Make Paypal checkout wait for checkbox state

I wrote a small module to display an “agree-to-the-terms”-checkbox in Drupal Commerce checkout pane, following the documentation HERE and tweaked it to my needs.

My PHP looks like this:

<?php

namespace Drupalcheckout_termsPluginCommerceCheckoutPane;

use Drupalcommerce_checkoutPluginCommerceCheckoutPaneCheckoutPaneBase;
use DrupalCoreFormFormStateInterface;

/**
 * AGB-Zustimmung fĂĽr den Checkout.
 *
 * @CommerceCheckoutPane(
 *   id = "checkout_terms_agb_zustimmung",
 *   label = @Translation("AGB Zustimmung"),
 *   display_label = @Translation("AGB Zustimmung"),
 *   default_step = "_review",
 *   wrapper_element = "fieldset",
 * )
 */

class CheckoutTermsAccept extends CheckoutPaneBase {

  /**
   * {@inheritdoc}
   */
    public function buildPaneForm(array $pane_form, FormStateInterface $form_state, array &$complete_form) {
      $pane_form('accept_terms') = (
        '#type' => 'checkbox',
        '#title' => 'Ich stimme den allgemeinen Geschäftsbedingungen zu',
        '#default_value' => 0,
        '#required' => TRUE
      );
      return $pane_form;
    }
    
}

This works perfect for custom multi-step-checkouts. The checkbox is unchecked by default, but the checkout can’t be finished without checking the box.

But when I choose the Commerce Paypal module to check out, I just ignores my checkbox and does the checkout anyway.

As I am pretty new to Drupal, I would be glad if someone could give me any advise on how to go from here. Is there any possibility to hook into the Paypal module from here and deactivate it as long as the checkbox is still unchecked? Or should I just do it in Javascript on that page?

Thank you very much in advance!