RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-209304

Dmitry's questions

Martin Hope
Dmitry
Asked: 2024-11-19 15:43:56 +0000 UTC

Django信号,如何连接到项目?

  • 5

我计划为门户添加一些功能。

这个想法是,当创建一个模型的实体时,保存时会自动创建另一个模型的实体。

目前,这是通过自定义方法实现的create(),该方法在创建模型时检查模型中是否存在必要的实体,验证并为另一个模型创建实体。一切都很混乱,并且不提供维护此类代码的灵活性。

我找到了这个参考:信号。

快速检查一下码头就可以清楚地知道这就是您所需要的。

伪代码来理解流程

class ModelA(models.Model):
    field1 = ...
    field2 = ...
    field3 = ...
    
class ModelB(models.Model):
    field1 = ...
    field2 = ...
    field3 = ...

from django.dispatch import receiver
from django.db.models.signals import post_save
@receiver(post_save, sender=ModelA)
def create_model_b(sender, instance, created, **kwargs):
    if created:
        # здесь логика для создания ModelB

问题:如何在项目中注册信号?信号是应用程序的一部分并且必须通过配置文件注册吗?

python
  • 1 个回答
  • 38 Views
Martin Hope
Dmitry
Asked: 2024-02-26 21:44:08 +0000 UTC

转换为json时出现TypeError异常

  • 5

发生了一些事情,我无法弄清楚在 DRF 视图之一中将字典转换为 json 时出现的问题

def languages(requset):
    if requset.method == "GET":
        langs = dict(settings.LANGUAGES)
        return JsonResponse(json.dumps(langs))

该变量langs包含一个普通的字典

{'en': 'English', 'en-uk': 'English (UK)', 'ru': 'Russian', 'nb': 'Norwegian Bokmål'}

但是当我访问这个端点时,我得到以下信息

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:\Python39\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Python39\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Python39\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Python39\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type __proxy__ is not JSON serializable

从视图中可以看出,这不是一个可以简单序列化并避免此问题的模型。该数据取自整个项目的语言设置。

有谁知道如何解决它?

python
  • 1 个回答
  • 40 Views
Martin Hope
Dmitry
Asked: 2022-09-19 06:13:44 +0000 UTC

是否可以使用端口 445 访问 API?

  • 0

网络专家的问题。让我们跳过我使用其他端口的动机和建议。

是否可以使用这个端口访问这种形式的API

curl my.domain:445/any/url

我正在尝试设置但没有得到积极的结果。端口是开放的,防火墙被检查并且端口对所有人开放。

Ubuntu 22.04 主机服务器,
API 测试绑定 -> nginx,guvicorn,unicorn,fastApi(本地测试,没有问题)

nginx
  • 0 个回答
  • 0 Views
Martin Hope
Dmitry
Asked: 2022-09-07 05:24:11 +0000 UTC

XUnit,最小起订量。模拟不返回数据

  • 0

就像处理世界上的测试一样.NET。我刚刚卡在一个测试上,我不明白为什么 mock 没有返回必要的数据集

模拟测试本身

[Fact]
public async Task GetAllRequestWithSuccess()
{
    // Arrange
    var testUsers = GetTestModelsUser();  // список необходимого типа данных, модели
    var testCount = testUsers.Count();  // количество вхождений
    var mockService = new Mock<IUserService>();
    var mockLogger = new Mock<ILogger<UserController>>();
    mockService.Setup(service => service.ListUsers(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()))
        .ReturnsAsync((testUsers, testCount));
    var controller = new UserController(mockLogger.Object, mockService.Object);

    // Act
    var actionResult = await controller.All();
    var objectReuslt = actionResult as OkObjectResult;
}

尚未添加断言块。

没有构建和运行错误,但actionResult它有一个BadRequestResult. 我进行了调试并确定模拟没有返回所需的数据集。也就是说,变量testUsers和testCount包含数据,但是当被调用时,mock 会ListUsers()返回(null, 0).

如何制作模拟作品?

UPD

听从enSO的建议,我尝试分别收集和传输数据,也没有带来结果。

[Fact]
public async Task GetAllRequestWithSuccess()
{
    // Arrange
    List<UserViewModel> testUsers = GetTestModelsUser();
    int testCount = testUsers.Count();
    (List<UserViewModel> users, int totalCount) t = (testUsers, testCount);
    var mockService = new Mock<IUserService>();
    var mockLogger = new Mock<ILogger<UserController>>();
    mockService.Setup(service => service.ListUsers(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>()))
        .ReturnsAsync(t);
    var controller = new UserController(mockLogger.Object, mockService.Object);
c#
  • 0 个回答
  • 0 Views
Martin Hope
Dmitry
Asked: 2022-08-30 16:42:47 +0000 UTC

XUnit 测试,检查异常

  • 1

告诉我如何确保在检查异常时测试不落空ObjectNotFoundError

我模拟了一项服务,在设置中我尝试实现抛出异常的模拟

public async Task GetRequestWithNoSucccessNotFound()
{
    var mockService = new Mock<ICompanyService>();
    var mockLogger = new Mock<ILogger<CompaniesController>>();
    mockService.Setup(service => service.GetCompany(It.IsAny<int>())).Throws<ObjectNotFoundException>();
    var controller = new CompaniesController(mockLogger.Object, mockService.Object);

    var result = await controller.Get(9999);

    var viewResult = Assert.IsType<RequestResponseModel<CompanyViewModel>>(result);
    Assert.False(result.IsSuccess);
}

服务方法如下所示

public async Task<CompanyViewModel> GetCompany(int companyId)
{
    var company = await contextDb.Companies.AsNoTracking().Where(p => p.Id == companyId).SelectCompany().FirstOrDefaultAsync();
    if (company == null)
    {
        throw new ObjectNotFoundException();
    }
    return company;
}

在这种情况下,测试失败并出现错误

System.NullReferenceException : Object reference not set to an instance of an object.

我怎样才能让假对象不放弃测试,但抛出一个在控制器中处理的异常?

UPD

得到

public async Task<RequestResponseModel<CompanyViewModel>> Get(int id)
{
    try
    {
        var company = await CompanyService.GetCompany(id);
        return RequestResponseModel<CompanyViewModel>.CreateSuccessObject(company);
    }
    catch (Exception e)
    {
        LogError(e);
        this.SetErrorResponseStatusCode(e);
        return RequestResponseModel<CompanyViewModel>.CreateRequestResponseErrorObject();
    }
}

SetErrorResponseStatusCode

public static void SetErrorResponseStatusCode(this ControllerBase controller, Exception exception)
    {
        // set http status based on type of exception
        if (exception is NotImplementedException)
        {
            controller.Response.StatusCode = (int)HttpStatusCode.NotImplemented;
        }
        else if (exception is ObjectNotFoundException)
        {
            controller.Response.StatusCode = (int)HttpStatusCode.NotFound; // вот здесь падает
        }
        else
        {
            controller.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
        }
    }

我想指出,只有测试下降。访问 API 时,一切正常。

c#
  • 1 个回答
  • 49 Views
Martin Hope
Dmitry
Asked: 2022-08-22 18:50:40 +0000 UTC

在 Windows 上将应用程序作为服务运行。失败 1053

  • 1

我按照本教程构建了应用程序。它启动,一切正常。

将应用程序移至服务器。由于我Publish在 Visual Studio 中构建应用程序,表明我想要一个文件,所以我正在迁移三个文件.exe, .pdb, settings.json.

通过sc,如手册中所示,我创建了一个服务

.\sc.exe create "service1" binpath="C:\path\to\publish\service.exe"

并在服务器上运行

.\sc.exe start "service1"

我收到一个错误

[SC] StartService FAILED 1053: 

The service did not respond to the start or control request in a timely fashion. windows server

当然,我搜索过,这是我尝试过的:

  1. ServicesPipeTimeout- 寄存器中的键操作
  2. 检查版本.NET并Runtime与他们一起
  3. 系统更新

给我一个提示如何捕捉阻止发射的东西?

适用于.NET 6.0、C#、Windows Server 2019的应用程序

程序.cs

using CsvToDdWorker;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Logging.EventLog;

using IHost host = Host.CreateDefaultBuilder(args)
    .UseWindowsService(options =>
    {
        options.ServiceName = "service1";
    })
    .ConfigureServices(services =>
    {
        LoggerProviderOptions.RegisterProviderOptions<
            EventLogSettings, EventLogLoggerProvider>(services);

        services.AddSingleton<SendToDbService>();
        services.AddHostedService<WindowsBackgroundService>();
    })
    .ConfigureLogging((context, logging) =>
    {
        logging.AddConfiguration(
            context.Configuration.GetSection("Logging"));
    })
    .Build();

await host.RunAsync();

WindowsBackgroundService.cs

namespace CsvToDdWorker
{
    public class WindowsBackgroundService : BackgroundService
    {
        private readonly SendToDbService _sendService;
        private readonly ILogger<WindowsBackgroundService> _logger;

        public WindowsBackgroundService(
            SendToDbService sendService,
            ILogger<WindowsBackgroundService> logger) =>
            (_sendService, _logger) = (sendService, logger);

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            try
            {
                while (!stoppingToken.IsCancellationRequested)
                {
                    _sendService.SendToDb(_logger);
                    await Task.Delay(TimeSpan.FromMinutes(20), stoppingToken);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "{Message}", ex.Message);
                Environment.Exit(1);
            }
        }
    }
}

UPD

我还尝试过使用应用程序启动期。改为秒、分、小时。这不是关于那个。

UPD1

在没有服务功能的服务器上开始执行SendToDb(_logger)。直通dotnet run。她工作没有问题。

c# .net
  • 1 个回答
  • 171 Views
Martin Hope
Dmitry
Asked: 2022-08-23 02:59:06 +0000 UTC

Visual Studio 2022,括号/引用所选部分

  • 1

我继续寻找 Visual Studio 2022 的功能和设置。

在Visual Studio代码中,选择区域然后单击左支架或报价标记时,功能非常方便,我在所需的选择器中找到了所选区域。像这样

在此处输入图像描述

但是 Visual Studio 并没有提供这种开箱即用的行为。

在此处输入图像描述

告诉我要查找的位置和设置。

visual-studio форматирование
  • 2 个回答
  • 160 Views
Martin Hope
Dmitry
Asked: 2022-08-12 01:17:44 +0000 UTC

光标所在的热键“突出显示单词”,Visual Studio

  • 2

我正在迁移到 Visual Studio 并尝试找到 VSCode 中提供的一些便利。

如何选择光标所在的单词?

在 VSCode 中,这是 - Ctrl+D

在 Visual Studio 中,我没有在光标的左右找到任何东西,但当光标在这个单词的中间时,却没有找到整个单词

这是组合Ctrl++ / ,Shift但这不是我要找的→←

visual-studio hotkeys
  • 2 个回答
  • 87 Views
Martin Hope
Dmitry
Asked: 2022-08-07 05:32:46 +0000 UTC

用于编写 c# 文档的 VSCode 扩展

  • 0

提示 VSCode 扩展以处理注释,以特殊方式设计(xml 注释),这是创建 xml 文件所必需的,然后可用于创建文档。

例如,这里有这样的东西

/// <summary>
/// что-то здесь
/// </summary>
c#
  • 1 个回答
  • 61 Views
Martin Hope
Dmitry
Asked: 2022-07-31 03:37:17 +0000 UTC

日期格式错误(发生异常:CLR/System.FormatException)。日期时间,C#

  • 1

是否有解析超过 24 小时的日期的规范解决方案?
例如,对于这样的

'2022.05.22 24:00'
'2022.05.22 24:10'

我发现的错误

Exception has occurred: CLR/System.FormatException
An unhandled exception of type 'System.FormatException' occurred in System.Private.CoreLib.dll: 'The DateTime represented by the string '2022.05.22 24:00' is not supported in calendar 'System.Globalization.GregorianCalendar'.'

给我这个的代码行

...
// values[0]="2022.05.22" и values[1]="24:00"
dateteime = DateTime.Parse((values[0] + ' ' +values[1]), CultureInfo.InvariantCulture),

我明白我可以做到Replace这一点

...
// values[0]="2022.05.22" и values[1]="24:00"
dateteime = DateTime.Parse((values[0] + ' ' +values[1].Replace("24:", "00:")), CultureInfo.InvariantCulture),

enSO 充斥着这类问题,但它们要么已经存在 10 年,要么没有价值,因为它们只解决了部分日期问题。或者,也许我在寻找错误的地方。

c# c#-8.0
  • 1 个回答
  • 50 Views
Martin Hope
Dmitry
Asked: 2022-07-28 06:07:47 +0000 UTC

时间:2019-05-10 标签:c#readcsv with 2 rows in header

  • 0

有人可以告诉我该怎么做。

有这样一个csv

;;temperature ID1;water ID1
;;C;moh
2022.05.22;07:00;8,5;499,24
2022.05.22;08:00;10,3;499,24

从给定的文件中可以看出,开头有两个标题行,甚至是空值。

在输出端,我想要这样一组值

public class Records
{
    public DateOnly Dates { get; set; }
    public string Times { get; set; }
    public float Moh { get; set; }
    public float Temperature { get; set; }

}

我试图通过手动处理来解决它,它自然有效。我唯一担心的是我必须用 分隔\r\n,因为不能保证文件中存在这个分隔符。这个

List<Records> records = new List<Records>();
using (var reader = new StreamReader("csvs\\test.csv"))
{
    while (!reader.EndOfStream)
    {
        var line = reader.ReadLine();
        var values = line.Split("\r\n");

        foreach (var item in values)
        {
            var values_sep = item.Split(";");
            try
            {
                var record = new Records{
                    Dates = DateOnly.Parse(values_sep[0]),
                    Times = values_sep[1],
                    Moh = float.Parse(values_sep[2]),
                    Temperature = float.Parse(values_sep[3])
                };
                records.Add(record);
            }
            catch (System.Exception)
            {
                System.Console.WriteLine("error");
            }
        }
    }
}

接下来,我尝试了 CsvHelper,但配置设置令人困惑,我设法仅通过switch/case. 我将存根放在表单中System.Console.WriteLine,以免弄乱代码。

var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
    HasHeaderRecord = false,
    Delimiter=";"
};
using (var reader = new StreamReader("csvs\\test.csv"))
using (var csv = new CsvReader(reader, config))
{
    while (csv.Read())
    {
        switch (csv.GetField(0))
        {
            case "":
                System.Console.WriteLine("Headers Here");
                break;
            default:
                System.Console.WriteLine("Record here");
                break;
        }
    }
}

实际上问题是,是否可以在没有拐杖和硬编码的情况下阅读这样的计划 csv 文件?或者我的解决方案在 C# 领域是否完全可以接受?

c# .net
  • 2 个回答
  • 87 Views
Martin Hope
Dmitry
Asked: 2022-07-24 02:45:25 +0000 UTC

Python:如何加速代码(技巧,官方指南)[关闭]

  • -1
关闭。这个问题不可能给出客观的答案。目前不接受回复。

想改进这个问题? 重新构建问题,以便可以根据事实和引用来回答。

4 个月前关闭。

改进问题

我的程序太慢了,如何加快速度?

python
  • 1 个回答
  • 49 Views
Martin Hope
Dmitry
Asked: 2022-07-20 07:37:56 +0000 UTC

VSCode 禅模式

  • 0

如何在 Visual Studio Code 中启用 Zen 模式?

在此处输入图像描述

visual-studio-code
  • 1 个回答
  • 463 Views
Martin Hope
Dmitry
Asked: 2022-08-10 20:39:24 +0000 UTC

Django 记录文件和控制台

  • 1

有一个工作django项目具有以下日志配置(settings.py)

LOGGING = {                                                                                                                 
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'logfile': {
            'class': 'logging.FileHandler',
            'filename': 'server.log',
        },
        'console':{
            'class':'logging.StreamHandler'
        }
    },
    'loggers': {
        'django': {
            'handlers': ['console', 'logfile'],
        },
    },
}

一切正常,日志已写入。

有时需要django通过命令行输入manage.py,像这样

(env) a@prod:~/path_to_manage$ python3 manage.py shell

在这个阶段我收到一个错误

raise ValueError('Unable to configure handler'
ValueError: Unable to configure handler'logfile'

我客观地清楚,在这种情况下,我无法访问server.log. 也就是说,如果您查看日志,那么我会看到

PermissionError:[Errno 13] 权限被拒绝:'/home/path_to_project/server.log'

谁知道如何配置配置以避免这种行为。也就是说,为了现在进入控制台django,我需要在设置中注释掉LOGGING,然后一切正常,我没有收到错误,但日志(这是合乎逻辑的)也没有写入。

python
  • 1 个回答
  • 10 Views
Martin Hope
Dmitry
Asked: 2022-08-08 19:38:25 +0000 UTC

Django从json文件填充数据库

  • 0

告诉我是否有现成的解决方案可以从 json 文件填充数据库。

模型类看起来像这样

class ServiceForEnd(models.Model):
    name = models.CharField(max_length=50, unique=True)
    url = models.CharField(max_length=100, unique=True, primary_key=True)
    methods = models.CharField(max_length=100)
    id_request = models.BooleanField(default=False)
    oData = models.BooleanField(default=False)
    id_obligatory = models.BooleanField(default=False)

json内容:

[
    {
        "name": "ReportingTrialBalance",
        "url": "Reporting/TrialBalance/",
        "methods": "GET",
        "id_request": false,
        "oData": true,
        "id_obligatory": false
    },
    {
        "name": "BankTransfer",
        "url": "Bank/BankTransfer/",
        "methods": "GET, POST, DELETE",
        "id_request": true,
        "oData": true,
        "id_obligatory": false
    }
]
python
  • 2 个回答
  • 10 Views
Martin Hope
Dmitry
Asked: 2022-07-07 20:28:30 +0000 UTC

检查 PostgreSQL 中是否存在表

  • 1

这里的问题更多是关于如何组织检查给定表是否存在。有两个功能。首先将元素保存到数据库:

def save_in_db(macAddress, topic, payload):
    conn = psycopg2.connect(dbname=DB_DATABASE,user= DB_USERNAME,password= DB_PASSWORD)
    exist_table = table_exists(conn, "stat"+macAddress)
    if exist_table == False:
        create_table_enhet(conn, macAddress)
    try:
        cur = conn.cursor()
        cur.execute("INSERT INTO stat" + macAddress + " (topic, message, ts) VALUES (%s,%s,%s)", (topic, payload ,datetime.now(),))
        conn.commit()
        cur.close()
        conn.close()
    except psycopg2.Error as e:
        logger.error("save_in_db",e)

第二个,它检查是否存在并从第一个调用:

def table_exists(conn, table_name):
    exists = False
    try:
        cur = conn.cursor()
        cur.execute("select exists(select relname from pg_class where relname='" + table_name + "')")
        exists = cur.fetchone()[0]
        cur.close()
        return exists
    except psycopg2.Error as e:
        logger.error ("table_exists", e)

有些情况会在connect-entity 中产生冲突。也就是说,有时会发生错误

当前事务被中止,命令被忽略直到事务块结束

通过connect-object 测试是否存在是否正确?还是在函数中table_exists()创建自己的更好connect,并在检查后关闭并创建一个新对象connect以进行操作save_in_db()?

python
  • 2 个回答
  • 10 Views
Martin Hope
Dmitry
Asked: 2022-05-13 18:44:29 +0000 UTC

使用 Nginx 的意外结果

  • 2

服务器上有两个portal,使用Nginx空间中的Host-name划分。SSL 是使用 certbot 组织的。

把证书整理好,拿掉两个证书后(和portal的工作无关,早就过期了),Nginx服务器崩溃了。systemctl status nginx.service最有趣的事情

● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2021-12-13 10:48:55 CET; 35min ago
       Docs: man:nginx(8)

错误:

des. 13 10:48:55 u nginx[248435]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
des. 13 10:48:55 u nginx[248435]: nginx: [emerg] still could not bind()
des. 13 10:48:55 u systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
des. 13 10:48:55 u systemd[1]: nginx.service: Failed with result 'exit-code'.
des. 13 10:48:55 u systemd[1]: Failed to start A high performance web server and a reverse proxy server.

令人惊讶的是,两个门户仍然可用(我马上说数据没有被缓存)。也就是说,从外部看,一切正常。

我检查了什么:

  1. ps -e,找到了 pid ,nginx这就是那里:三个进程,看起来像这样
● snap.certbot.certbot.***********.scope
     Loaded: loaded (/run/systemd/transient/snap.certbot.certbot.***********.scope; transien>
  Transient: yes
     Active: active (running) since Mon 2021-12-13 09:39:30 CET; 1h 35min ago
  1. 我试图杀死与 相关的进程nginx,但它们再次上升(我systemd/system/nginx.service删除了自动重新加载并通过 daemon-reload 重新启动,它没有帮助)
  2. 我试图杀死端口 80 上的进程,但它们又上升了

谁知道问题的根源以及在哪里挖掘以使其nginx“按应有的方式”工作?或者你能澄清我做错了什么吗

UPD

添加配置检查nginx

~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

检查端口表明 nginx 正在使用它们

~$ sudo lsof -i -P -n | grep LISTEN
nginx     245336        www-data    6u  IPv4 3142018      0t0  TCP *:80 (LISTEN)
nginx     245336        www-data    7u  IPv6 3142019      0t0  TCP *:80 (LISTEN)
nginx     245336        www-data    8u  IPv6 3142020      0t0  TCP *:443 (LISTEN)
nginx     245336        www-data    9u  IPv4 3142021      0t0  TCP *:443 (LISTEN)
nginx     245337        www-data    6u  IPv4 3142018      0t0  TCP *:80 (LISTEN)
nginx     245337        www-data    7u  IPv6 3142019      0t0  TCP *:80 (LISTEN)
nginx     245337        www-data    8u  IPv6 3142020      0t0  TCP *:443 (LISTEN)
nginx     245337        www-data    9u  IPv4 3142021      0t0  TCP *:443 (LISTEN)
nginx     245338        www-data    6u  IPv4 3142018      0t0  TCP *:80 (LISTEN)
nginx     245338        www-data    7u  IPv6 3142019      0t0  TCP *:80 (LISTEN)
nginx     245338        www-data    8u  IPv6 3142020      0t0  TCP *:443 (LISTEN)
nginx     245338        www-data    9u  IPv4 3142021      0t0  TCP *:443 (LISTEN)
~$ sudo ps -ax | grep nginx
 245336 ?        S      0:00 nginx: worker process
 245337 ?        S      0:00 nginx: worker process
 245338 ?        S      0:00 nginx: worker process
 250704 pts/7    S+     0:00 grep --color=auto nginx

linux
  • 3 个回答
  • 10 Views
Martin Hope
Dmitry
Asked: 2022-03-20 15:46:26 +0000 UTC

反应原生文档

  • 0

是时候编写代码文档了。
由于该项目对我来说是一个全新的领域并且属于我不喜欢的(我的主观意见)javascript并且包括功能组件React,因此实际的问题是:
组件是如何记录的React(如果很重要,它们绝对都是功能性的),包括那些包含嵌套组件的?您可以诚实地忽略什么?

javascript
  • 2 个回答
  • 10 Views
Martin Hope
Dmitry
Asked: 2022-03-14 20:42:22 +0000 UTC

您试图在一个本来是不可变且已被冻结的对象上设置键 `port` 的值为 `8883`

  • 0

如何修复此错误。

您试图用一个对象上port的值设置键,该8883对象是不可变的并且已被冻结

我在尝试为 MQTT 连接重新创建客户端后得到它。我使用的是:react-native,对于 mqtt 连接,这个库是sp-react-native-mqtt。到目前为止,我仅在 android 设备上进行调试。

它是这样工作的:

  1. 我打开屏幕 => 请求 REST API
  2. 我得到配置 => 创建一个 MQTT 客户端
  3. 我连接 MQTT 客户端
  4. 消息传递工作
  5. 我单击标题中的后退按钮 => 正在处理禁用/删除 MQTT 客户端
  6. 我切换到 MQTT 客户端应该再次连接的另一个屏幕
  7. 提交(发布)=> 抛出此错误

我的理解是,有一些实体 key port,在初始化新客户端时无法覆盖。
它在哪里以及如何处理它?

javascript
  • 1 个回答
  • 10 Views
Martin Hope
Dmitry
Asked: 2022-03-13 16:44:05 +0000 UTC

Python 3.10 中的匹配案例构造

  • 2

2021 年 10 月 4 日,Python 3.10 发布。match-case在其他更新中,使用称为结构模式匹配的构造的能力或pattern matching

如何使用这个设计?

对于早期版本的 Python,请参阅此 ruSO 答案中的实现(类似于 switch-case 构造)。

python
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5